Skip to content

Add protected browser storage example#36846

Merged
guardrex merged 1 commit intomainfrom
guardrex/state-mgmt-addl-example
Mar 6, 2026
Merged

Add protected browser storage example#36846
guardrex merged 1 commit intomainfrom
guardrex/state-mgmt-addl-example

Conversation

@guardrex
Copy link
Collaborator

@guardrex guardrex commented Mar 6, 2026

Fixes #35905

Tom, Wade ... Just need one review to get this in.

This PR adds a state management example for >=9.0 that uses RendererInfo.IsInteractive to decide when to tap browser storage and render content. It's the more modern, correct way to do it since that API came out at 9.0. We'll retain the other examples for earlier versions.


Internal previews

📄 File 🔗 Preview link
aspnetcore/blazor/state-management/protected-browser-storage.md aspnetcore/blazor/state-management/protected-browser-storage

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Blazor (ASP.NET Core >= 9.0) example to the protected browser storage article showing how to use RendererInfo.IsInteractive to safely access browser storage when prerendering is enabled, while retaining the pre-9.0 example approach.

Changes:

  • Add a new >= aspnetcore-9.0 example that gates browser-storage access on RendererInfo.IsInteractive (and links to render mode detection guidance).
  • Split the existing sample into a >= aspnetcore-5.0 < aspnetcore-9.0 moniker range to preserve the pre-.NET 9 pattern.

@guardrex guardrex requested review from tdykstra and wadepickett March 6, 2026 12:08
Copy link
Contributor

@wadepickett wadepickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

@guardrex guardrex removed the request for review from tdykstra March 6, 2026 22:23
@guardrex guardrex merged commit 85dd600 into main Mar 6, 2026
8 checks passed
@guardrex guardrex deleted the guardrex/state-mgmt-addl-example branch March 6, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Detect whether the current render mode is interactive before accessing browser storage

3 participants