Skip to content

Blazor Pre-rendering and PersistingComponentStateSubscription not working correctly with dotnet 9? #34229

@MattCost

Description

@MattCost

Description

Steps to reproduce

  1. Make a new template dotnet new blazor
  2. add @rendermode InteractiveServer to the weather page
  3. Start the app
  4. Go to /weather
    1 Observe the double rendering in action.
  5. Add in code from https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerender?view=aspnetcore-9.0 to use PersistingComponentStateSubscription to save data
  6. Restart the app
  7. Navigate back and forth using the navigation links on the left hand side. (between home and weather and counter). Most times the double rendering still occurs on the weather page, sometimes it does not.
  8. Navigate to /home via the link on the left.
  9. Manually type in /weather into the url
  10. Double rendering never occurs when manually typing in the url

Questions

Why does the persisting only work sometimes?

The page has the following note If the app adopts interactive routing and the page is reached via an internal navigation, prerendering doesn't occur. Therefore, you must perform a full page reload for the PrerenderedCounter2 component to see the following output.

This doesn't make sense. Using internal navigation, prerendering is still occuring, and persisting is NOT working to stop it. Is this note out of date?

Are there changes in dotnet 9 to how the PersistingComponentStateSubscription works? or how pre-rendering works?

Not sure if this needs to be a bug report in another repo, or if this is just a documentation issue.

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/components/prerender?view=aspnetcore-9.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/components/prerender.md

Document ID

ffdc8df3-55a8-b757-d4e6-38c104916002

Article author

@guardrex

Related Issues

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions