Skip to content

Blazor [PersistentState(AllowUpdates = true)] issue with @rendermode InteractiveWebAssembly #63996

Closed

Description

@SimSef

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
  1. Open http://localhost:5041/persist-demo-b in Chrome with DevTools open.
  2. 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'.
    
  3. Use the on-page buttons (which call NavigateTo(..., forceLoad: false)) to switch between /persist-demo-a and /persist-demo-b.
  4. 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.
  5. 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)

Activity

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

    @MihuBot

    I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  3. SimSef commented on Oct 10, 2025

    @SimSef
    Author

    Similar issue but the Pre- render happens on each enhanced nav to InteractiveWebAssembly. And the issue is that the hydration works only on full page reload (when navigating to InteractiveWebAssembly page it correctly takes the pre-rendered data and carries it over to hydration) but on enhanced nav it pre-renders (which given the docs shouldnt be the case) but then also it doesnt carry it over to the hydration state. Meaning 2 issues occur at the same time.

  4. added this to the .NET 11 Planning milestone on Oct 11, 2025
  5. javiercn commented on Aug 13, 2026

    @javiercn
    Member

    This was fixed by #68088, which corrected persisted-state discovery when enhanced navigation activates components on an already-running runtime.

    I verified the original two-page Interactive WebAssembly scenario on current main:

    • [PersistentState(AllowUpdates = true)] is restored before interactive initialization on repeated enhanced navigations.
    • Enhanced navigation preserves the document.
    • The browser console and network log contain no errors.

    Reverting the #68088 ordering change reproduces the failure for both WebAssembly and Server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-blazorinvestigate

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions