From 570200b38fc8b7585ab95bf896943de66ba8ba72 Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Thu, 20 Aug 2026 09:52:53 -0400 Subject: [PATCH] Improve description of `AllowUpdates` (#37494) --- .../prerendered-state-persistence.md | 22 +++++++++++++++++-- aspnetcore/blazor/state-management/server.md | 4 ++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/aspnetcore/blazor/state-management/prerendered-state-persistence.md b/aspnetcore/blazor/state-management/prerendered-state-persistence.md index 7faf63001478..714e29729002 100644 --- a/aspnetcore/blazor/state-management/prerendered-state-persistence.md +++ b/aspnetcore/blazor/state-management/prerendered-state-persistence.md @@ -5,7 +5,7 @@ author: guardrex description: Learn how to persist user data (state) in Blazor apps using Blazor's Persistent Component State service. monikerRange: '>= aspnetcore-8.0' ms.author: wpickett -ms.date: 08/03/2026 +ms.date: 08/20/2026 uid: blazor/state-management/prerendered-state-persistence --- # ASP.NET Core Blazor prerendered state persistence @@ -471,7 +471,7 @@ Blazor supports handling persistent component state during [enhanced navigation] By default, persistent component state is only loaded by interactive components when they're initially loaded on the page. This prevents important state, such as data in an edited webform, from being overwritten if additional enhanced navigation events to the same page occur after the component is loaded. -If the data is read-only and doesn't change frequently, opt-in to allow updates during enhanced navigation by setting `AllowUpdates = true` on the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute). This is useful for scenarios such as displaying cached data that's expensive to fetch but doesn't change often. The following example demonstrates the use of `AllowUpdates` for weather forecast data: +If the data is read-only and doesn't change frequently, opt-in to allow updates during enhanced navigation by setting to `true` on the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute). This is useful for scenarios such as displaying cached data that's expensive to fetch but doesn't change often, such as weather forecast data in the following example: ```csharp [PersistentState(AllowUpdates = true)] @@ -483,6 +483,24 @@ protected override async Task OnInitializedAsync() } ``` +:::moniker-end + +:::moniker range=">= aspnetcore-11.0" + +> [!NOTE] +> doesn't control whether the current property value is captured by [circuit state persistence](xref:blazor/state-management/server#circuit-state-persistence) when the circuit pauses, including an automatic pause caused by [tab inactivity](xref:blazor/state-management/server#automatic-circuit-pause-on-tab-inactivity). + +:::moniker-end + +:::moniker range=">= aspnetcore-10.0 < aspnetcore-11.0" + +> [!NOTE] +> doesn't control whether the current property value is captured by [circuit state persistence](xref:blazor/state-management/server#circuit-state-persistence) when the circuit pauses. + +:::moniker-end + +:::moniker range=">= aspnetcore-10.0" + To skip restoring state during prerendering, set `RestoreBehavior` to `SkipInitialValue`: ```csharp diff --git a/aspnetcore/blazor/state-management/server.md b/aspnetcore/blazor/state-management/server.md index 404f439666eb..ebc61b2e807f 100644 --- a/aspnetcore/blazor/state-management/server.md +++ b/aspnetcore/blazor/state-management/server.md @@ -5,7 +5,7 @@ author: guardrex description: Learn how to persist user data (state) in server-side Blazor apps. monikerRange: '>= aspnetcore-3.1' ms.author: wpickett -ms.date: 07/23/2026 +ms.date: 08/18/2026 uid: blazor/state-management/server --- # ASP.NET Core Blazor server-side state management @@ -254,7 +254,7 @@ For elements without Blazor bindings (for example, ``, WebRTC connection > @SelectedFileName > > @code { -> [PersistentState(AllowUpdates = true)] +> [PersistentState] > public string? SelectedFileName { get; set; } > > private async Task HandleFileSelected(ChangeEventArgs e)