Repository navigation
[release/11.0-preview7] Update the weather page in the Blazor Web App template to persist prerendered state - #67989
Merged
akoeplinger merged 4 commits intoJul 24, 2026
Conversation
…ate] attribute Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
The Weather page is only rendered interactively when interactivity is applied at the root (Global). In per-page interactivity configurations the page is static SSR with [StreamRendering], so persisting its prerendered state does not apply. With --interactivity Auto (per-page), the resulting server+WebAssembly composite persistence store triggers ComponentStatePersistenceManager.InferRenderModes, which threw 'The registered callback PersistProperty must be associated with a component or define an explicit render mode type during registration' because the static component has no render mode, failing the Blazor template tests. Gate the [PersistentState] attribute behind InteractiveAtRoot so it is only emitted when the Weather page is actually interactive (the scenario the originating issue describes), matching the existing [StreamRendering] conditional and eliminating the crash. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 411ebb3a-a72c-434e-94bd-ee0352399c87
oroztocil
approved these changes
Jul 24, 2026
maraf
approved these changes
Jul 24, 2026
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #64644 to release/11.0-preview7
/cc @ilonatommy @copilot
Update the weather page in the Blazor Web App template to persist prerendered state
Template code change - we start using perisistive state in interactive tempaltes.
Description
When navigating directly to the weather page in an interactive Blazor Web App, users see the prerendered content, then a flash of "Loading...", then the data again. This is particularly noticeable due to the 500ms simulated delay in the template.
This fix uses [PersistentState(AllowUpdates = true)] to persist the prerendered forecasts and restore them when interactive mode starts:
Add [PersistentState(AllowUpdates = true)] attribute to Forecasts property in Weather.razor
Change from private field to public property (required for the attribute)
Make WeatherForecast class public (required for JSON serialization)
Skip data loading in OnInitializedAsync when state is already restored
Set AllowUpdates = true to enable state updates during enhanced navigation
Fixes #51205
Customer Impact
Users creating new Blazor Web App projects from the template experience a visible flash of "Loading..." when navigating directly to the weather page. This fix eliminates that flash by persisting the prerendered state across the prerender-to-interactive transition.
Regression?
Risk
Not a framework change, just an enhancement to templates.
Verification
Packaging changes reviewed?