Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to persist prerendered state when using Blazor server-side rendering #49733

Closed
danroth27 opened this issue Jul 30, 2023 · 9 comments
Assignees
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Milestone

Comments

@danroth27
Copy link
Member

We provide a persist-component-state tag helper for persisting state used during prerendering from an MVC view or Razor Page. We need a way to persist the component state from a Blazor component when using server-side rendering (SSR).

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Jul 30, 2023
@mkArtakMSFT mkArtakMSFT added enhancement This issue represents an ask for new feature or an enhancement to an existing one bug This issue describes a behavior which is not expected - a bug. and removed enhancement This issue represents an ask for new feature or an enhancement to an existing one labels Jul 31, 2023
@mkArtakMSFT mkArtakMSFT modified the milestones: 8.0-rc2, 8.0-rc1 Jul 31, 2023
@Alerinos
Copy link

Alerinos commented Jul 31, 2023

@danroth27
This is quite problematic, for example if we want to transport cookies then we have to go through "Component"
Example:

    <component type="typeof(Areas.Web.App)"
               render-mode="ServerPrerendered"
               param-GetIP="@GetIP"
               param-GetAgent="@GetAgent"
               param-GetCookies="@GetCookies"
               param-SessionUser=@SessionStat.User />

If this is not done, we have this effect.
The first reload (server) is correct, the second reload causes the Scope circuit to disappear.
https://gyazo.com/dcae15aebf6269f1023a8f185920a9e1


edit:
If we do away with _host.cshtml and there is no longer a <component>, how can we pass parameters to the Blazor circuit?

@oliverw
Copy link

oliverw commented Oct 17, 2023

So how is this now actually done from an application perspective?

@oliverw
Copy link

oliverw commented Oct 17, 2023

@oliverw It's documented here:

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerendering-and-integration?view=aspnetcore-7.0&pivots=webassembly#persist-prerendered-state

Thanks. Not sure if that has been updated for Blazor 8 Web Apps. I don't have a .cshtml file.

@marinasundstrom
Copy link

marinasundstrom commented Oct 17, 2023

@oliverw Woops. Sorry. It was the wrong link: https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerender?view=aspnetcore-8.0#persist-prerendered-state

I thought it switched over to the .NET 8 version when I selected it. But it is not the same document.

But basically, it is the same. Just no need for a the tag helper anymore.

@oliverw
Copy link

oliverw commented Oct 17, 2023

@oliverw It's documented here:

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerendering-and-integration?view=aspnetcore-7.0&pivots=webassembly#persist-prerendered-state

Thanks again. Is that supposed to work with @rendermode InteractiveAuto ?

@marinasundstrom
Copy link

@oliverw Yes. Since it works with both InteractiveServer and InteractiveWebAssembly when components are prerendered.

@oliverw
Copy link

oliverw commented Oct 17, 2023

@oliverw Yes. Since it works with both InteractiveServer and InteractiveWebAssembly when components are prerendered.

Cool. Trying it out 😄

@marinasundstrom
Copy link

@oliverw 👍🏻 🙂 If you want an example, then there is this: https://github.com/marinasundstrom/Blazor8Test/blob/main/src/Client/Pages/FetchData.razor

@dotnet dotnet locked as resolved and limited conversation to collaborators Nov 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components bug This issue describes a behavior which is not expected - a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants