Minimal reproduction for the Blazor Web App bug where [PersistentState(AllowUpdates = true)] fails to hydrate state when navigating between pages rendered with @rendermode InteractiveWebAssembly.
- .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
git clone https://github.com/CoCoNuTeK/-PersistentState-AllowUpdates-true-issue-when-InteractiveWebAssembly.git
cd -PersistentState-AllowUpdates-true-issue-when-InteractiveWebAssembly/PersistenceStateIssue
dotnet runOpen http://localhost:5041/persist-demo-a. For clarity:
- Both
PersistDemoAandPersistDemoBuse@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)
- Switch between persist-demo-b and persist-demo-a;
- 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
- 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:
- [PersistentState(AllowUpdates = true)] is ignored when @rendermode InteractiveWebAssembly
- 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)]