-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Open
Labels
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When a Blazor Web App component uses @rendermode InteractiveWebAssembly
with [PersistentState(AllowUpdates = true)]
, enhanced navigation ignores the persisted snapshot. Navigating back to the page causes the WASM instance to rerun OnInitializedAsync
, regenerate data, and overwrite the server-provided value—even though the initial hydration works. Full reloads (forceLoad: true
) or @rendermode InteractiveServer
preserve state correctly.
To 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-b
in Chrome with DevTools open. - Observe initial console output, for example:
[PersistDemoB] Skipping random value generation because state already contains '39'. [PersistDemoA] No persisted random value found. Simulating load before generating a new value. [PersistDemoA] Generated random value '72'. [PersistDemoB] No persisted random value found. Simulating load before generating a new value. [PersistDemoB] Generated random value '25'.
- Use the on-page buttons (which call
NavigateTo(..., forceLoad: false)
) to switch between/persist-demo-a
and/persist-demo-b
. - Each enhanced navigation triggers another execution of
OnInitializedAsync
in the WASM instance and generates a new random value, despite the Network tab showing the prerender and[PersistentState(AllowUpdates = true)]
being present. - Setting
forceLoad: true
avoids the issue but removes enhanced navigation.
Exceptions (if any)
None.
Further technical details
details of dotnet --info
.NET SDK (reflecting any global.json):
Version: 10.0.100-rc.1.24452.12 (arm64)
OS Name: macOS
OS Version: 14.xx (Sonoma)
RID: osx-arm64
- IDE: Visual Studio Code Version:
1.104.3
Commit: 385651c938df8a906869babee516bffd0ddb9829
Date: 2025-10-02T12:30:51.747Z
Electron: 37.3.1
ElectronBuildId: 12404162
Chromium: 138.0.7204.235
Node.js: 22.18.0
V8: 13.8.258.31-electron.0
OS: Darwin arm64 24.6.0
Repro repository: https://github.com/CoCoNuTeK/-PersistentState-AllowUpdates-true-issue-when-InteractiveWebAssembly
Steps To Reproduce
in repo README.md
Exceptions (if any)
None
.NET Version
.NET SDK: 10.0.0-rc.1 (arm64 build)