Skip to content

[release/11.0-preview7] Update the weather page in the Blazor Web App template to persist prerendered state - #67989

Merged
akoeplinger merged 4 commits into
release/11.0-preview7from
backport/pr-64644-to-release/11.0-preview7
Jul 24, 2026
Merged

akoeplinger merged 4 commits into
release/11.0-preview7from
backport/pr-64644-to-release/11.0-preview7

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

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?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Not a framework change, just an enhancement to templates.

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

Copilot AI and others added 4 commits July 24, 2026 07:39
…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
@github-actions
github-actions Bot requested a review from a team as a code owner July 24, 2026 07:39
@ilonatommy ilonatommy self-assigned this Jul 24, 2026
@ilonatommy
ilonatommy requested a review from oroztocil July 24, 2026 08:36
@ilonatommy ilonatommy added this to the 11.0-preview7 milestone Jul 24, 2026
@akoeplinger
akoeplinger merged commit 949e3a5 into release/11.0-preview7 Jul 24, 2026
23 checks passed
@akoeplinger
akoeplinger deleted the backport/pr-64644-to-release/11.0-preview7 branch July 24, 2026 11:56
@Youssef1313 Youssef1313 added the tell-mode Indicates a PR which is being merged during tell-mode label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tell-mode Indicates a PR which is being merged during tell-mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants