Skip to content

PersistentState does not work between enhanced navigation SSR and WASM pages #63895

Closed

Description

@Markz878

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

If I navigate from a SSR page with enhanced navigation to a WASM page (@rendermode InteractiveWebAssembly at the top), the PersistentState feature doesn't work.

There is a mention of this in the docs (although it's not clear whether this is an interactive routing)
"If the app adopts interactive routing and the page is reached via an internal enhanced navigation, prerendering doesn't occur. Therefore, you must perform a full page reload for the component to see the following output."

But there is also this in the docs:
"Blazor supports handling persistent component state during enhanced navigation. State persisted during enhanced navigation can be read by interactive components on the page."

So is it so that the PersistentState feature is intentionally not meant to work in this situation, and that all pages should be SSR rendered with only Components marked with @rendermode="InteractiveWebAssembly"?

If yes, could this be mentioned in the docs? And is this feature possible to implement in the future?

Describe the solution you'd like

I would like PersistentState to work between enhanced navigation SSR and WASM pages.

Additional context

I can provide a repro if needed.

Activity

  1. added
    area-blazor
    on Oct 1, 2025
  2. MihuBot commented on Oct 1, 2025

    @MihuBot
  3. javiercn commented on Oct 1, 2025

    @javiercn
    Member

    @Markz878 thanks for contacting us.

    Can you provide a minimal repro project that demonstrates the issue?

  4. added
    Needs: Author Feedback
    Needs: Repro
    on Oct 1, 2025
  5. Markz878 commented on Oct 1, 2025

    @Markz878
    Author

    @javiercn Here is the repro project:
    https://github.com/Markz878/PersistentStateIssue

    If you navigate between the Home and Counter page a few times, you see that on each navigation to Counter page the CounterClientService is invoked (in browser console and network tabs), which in turn calls the API endpoint, even though there is no need, representing a duplicate invocation of for example a database call.

    I tried all variations of the PersistentState properties, but I could not see a difference.

    Disabling enhanced navigation in App.razor solves this issue, but it is another thing that new Blazor developers won't know about.
    Would be great if this could work without that.

  6. added
    Needs: Attention 👋
    and removed
    Needs: Author Feedback
    on Oct 1, 2025
  7. javiercn commented on Oct 2, 2025

    @javiercn
    Member

    @Markz878 thanks for the additional details.

    From what I can observe right now, something weird is going on that has to do with some persistent component state updates being lost. (see the warnings). I suspect this might be an issue on the JS bits that collect the state, and would explain why our E2E tests didn't necessarily catch this.

    Here we can see a couple of successful transitions

    info: BlazorApp4.Components.Pages.Home[0]
          Rendering Home. Renderer: Static
    info: BlazorApp4.Client.Pages.Counter[0]
          Name: Static, State: null
    info: BlazorApp4.CounterServerService[0]
          Called from Static. Generated count: 164
    info: BlazorApp4.Client.Pages.Counter[0]
          Name: Server, State: 164
    info: BlazorApp4.Client.Pages.Counter[0]
          Finished rendering: Server with count: 164
    info: BlazorApp4.Components.Pages.Weather[0]
          Starting to load weather data. Renderer: Static
    info: BlazorApp4.Client.Pages.Counter[0]
          Name: Static, State: null
    info: BlazorApp4.CounterServerService[0]
          Called from Static. Generated count: 147
    info: BlazorApp4.Client.Pages.Counter[0]
          Name: Server, State: 147
    info: BlazorApp4.Client.Pages.Counter[0]
          Finished rendering: Server with count: 147
    info: BlazorApp4.Components.Pages.Home[0]
          Rendering Home. Renderer: Static

    Here we see an example where things go wrong

    info: BlazorApp4.Client.Pages.Counter[0]
          Name: Static, State: null
    info: BlazorApp4.CounterServerService[0]
          Called from Static. Generated count: 102
    warn: BlazorApp4.Client.Pages.Counter[0]
          Name: Server, State: null
    info: BlazorApp4.CounterServerService[0]
          Called from Server. Generated count: 124
    info: BlazorApp4.Client.Pages.Counter[0]
          Finished rendering: Server with count: 124
  8. added
    bug
    and removed
    Needs: Attention 👋
    Needs: Repro
    on Oct 2, 2025
  9. added this to the milestone on Oct 2, 2025
  10. Markz878 commented on Oct 2, 2025

    @Markz878
    Author

    @javiercn Glad you were able to track down the bug. I suppose this will be a common pattern in SSR + WASM scenarios, so I agree it's important to get it fixed for 10.0. Thanks for your effort!

  11. AlexKovynev commented on Oct 12, 2025

    @AlexKovynev

    @javiercn maybe better move to 10.0.0 milestone cause here nothing resolved :(

  12. modified the milestones: , 10.0.x on Oct 17, 2025
  13. Markz878 commented on Oct 31, 2025

    @Markz878
    Author

    @javiercn Could you tell what is the status on this, are we getting a fix for this in .NET 10?

  14. Markz878 commented on Nov 11, 2025

    @Markz878
    Author

    @javiercn @danroth27 Why doesn't any template you have show this simple data access pattern for a SSR+WASM Blazor app? You expect developers to come up with our own patterns for this, but even this simple pattern has a bug in it. If you would dogfood your own framework even a little bit you would notice these kinds of problems.

    I'm very disappointed that this wasn't fixed for .NET 10, is it going to be another 2 years for this to be fixed for LTS release?
    How is Blazor ever going to get any serious traction with bugs like this?

  15. danroth27 commented on Nov 11, 2025

    @danroth27
    Member

    @Markz878 We've queued this up for investigation for a potential .NET 10 servicing release.

  16. MrScottyTay commented on Feb 17, 2026

    @MrScottyTay

    Any traction on this yet?

    I get what I think is a similar issue (but with SSR and InteractiveServer) where I have a scoped service registered with persistence in the Program.cs. Values marked with [PersistentState] carry over between SSR and InteractiveServer rendering as expected. However as soon as I run code via OnAfterRender the service is back to default values, it didn't persist.

  17. added theissue type on May 1, 2026
  18. added a commit that references this issue on Aug 10, 2026
    4ca8f9a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-blazorbug

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions