Skip to content

I built a minimal, production-style repro to provide actionable feedback to Microsoft’s .NET/Blazor team. It isolates a state hydration mismatch between SSR prerender and Interactive WebAssembly during enhanced navigation when using PersistentState(AllowUpdates=true) on .NET 10 RC.

Notifications You must be signed in to change notification settings

SimSef/-PersistentState-AllowUpdates-true-issue-when-InteractiveWebAssembly

Repository files navigation

PersistentState AllowUpdates + Interactive WASM Repro

Minimal reproduction for the Blazor Web App bug where [PersistentState(AllowUpdates = true)] fails to hydrate state when navigating between pages rendered with @rendermode InteractiveWebAssembly.

Environment

  • .NET SDK: 10.0.0-rc.1 (arm64 build)
  • Host OS: macOS Sonoma 14.xx (Apple Silicon)
  • Browser: Google Chrome (desktop) with DevTools console open

Reproduce

git clone https://github.com/CoCoNuTeK/-PersistentState-AllowUpdates-true-issue-when-InteractiveWebAssembly.git
cd -PersistentState-AllowUpdates-true-issue-when-InteractiveWebAssembly/PersistenceStateIssue
dotnet run

Open http://localhost:5041/persist-demo-a. For clarity:

  • Both PersistDemoA and PersistDemoB use @rendermode InteractiveWebAssembly
  • Each component delays for 2 seconds, then stores a random 1‑100 value via [PersistentState(AllowUpdates = true)]
  • Navigation buttons use NavigationManager.NavigateTo(..., forceLoad: false) (enhanced navigation)

What to check

  1. Switch between persist-demo-b and persist-demo-a;
  2. You will see that on the page load the persist-demo-a correctly takes state from the prerendering; however on enhanced back and forth navigation prerendering happens, but it also happens 2nd time on the client side, meaning the [PersistentState(AllowUpdates = true)] is ignored on enhanced nav
  3. check console logs + network wehre u will see on navigations that there is a different number generated in network tab then in on the page

Meaning 2 issues:

  1. [PersistentState(AllowUpdates = true)] is ignored when @rendermode InteractiveWebAssembly
  2. Internal navigation with interactive routing doesn't use prerendering because the page is already interactive. - is broken given prerender should happen only the 1st time page is loaded not each time during enhanced Nav

I didnt have these issues if on each Nav we force load OR we use InteractiveServer with the same [PersistentState(AllowUpdates = true)]

About

I built a minimal, production-style repro to provide actionable feedback to Microsoft’s .NET/Blazor team. It isolates a state hydration mismatch between SSR prerender and Interactive WebAssembly during enhanced navigation when using PersistentState(AllowUpdates=true) on .NET 10 RC.

Topics

Resources

Stars

Watchers

Forks