Blazor .NET 11 Circuit Auto-Pause: Configure and Test Hidden Tabs

Blazor Interactive Server in .NET 11 can opt into automatic circuit pause when a browser tab stays hidden. Evaluate it for screens users leave open, then test how the page resumes and which state needs durable storage.

What can auto-pause free?

An Interactive Server circuit holds server-side component state and communicates over SignalR. Auto-pause starts a delay when the tab becomes hidden. If the tab returns before the delay expires, the automatic pause does not happen. If it remains hidden, the feature can pause the circuit and release resources associated with the inactive tab.

This opt-in is about browser visibility, so a visible tab with no clicks is a separate case. A background business job must have its own lifecycle. If a job must continue after the circuit is paused, drive it through a durable queue or worker with independent state.

Interactive Server circuit starts. Tab becomes hidden. Hidden delay reaches threshold. Return to tab and check state.
Interactive Server circuit starts. Tab becomes hidden. Hidden delay reaches threshold. Return to tab and check state.

Configure a small interactive project

Use .NET 11 and the Microsoft.AspNetCore.Components.Server.AutoPause package. The sample configures a short ten-second delay for manual testing. Microsoft documents a default delay of two minutes. For an existing application, add the package and browser option to the existing Razor Components endpoint configuration.

Sample.csproj
<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>net11.0</TargetFramework><OutputType>Exe</OutputType><ImplicitUsings>enable</ImplicitUsings><Nullable>enable</Nullable><RootNamespace>Sample</RootNamespace></PropertyGroup><ItemGroup><PackageReference Include="Microsoft.AspNetCore.Components.Server.AutoPause" Version="11.0.0" /></ItemGroup></Project>
Program.cs
using Microsoft.AspNetCore.Components;
using Sample;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
var app = builder.Build();
app.UseAntiforgery();
app.MapStaticAssets();
app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode()
    .WithBrowserOptions(options => options.AddAutoPause(p =>
        p.HiddenDelay = TimeSpan.FromSeconds(10)));
app.Run();
_Imports.razor
@using Microsoft.AspNetCore.Components
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
App.razor
<!doctype html>
<html lang="en">
<head><meta charset="utf-8" /><base href="/" /><title>ASP.NET PB lab</title></head>
<body>
<Router AppAssembly="typeof(App).Assembly">
  <Found Context="data"><RouteView RouteData="data" /></Found>
</Router>
<script src="_framework/blazor.web.js"></script>
</body>
</html>
Home.razor
@page "/"
@rendermode InteractiveServer
<h1>Circuit pause lab</h1>
<p>Clicks in this circuit: @clicks</p>
<button @onclick="() => clicks++">Increment</button>
@code { private int clicks; }

Run dotnet run --urls http://localhost:5103 and open the root URL in a browser. Increment the counter and confirm it responds. Switch to another tab for less than ten seconds and return. Repeat with a longer interval. Compare browser network activity, server observations, and the displayed counter when you return.

The counter is intentionally ordinary component memory. Observe what happens after resuming rather than assuming arbitrary state persists. If a value is required after pause, verify Blazor’s supported persisted-state options and whether your model is serializable. Keep important work, such as a confirmed order or a saved form, in application storage.

What should a production test cover?

Scenario What to observe
Short tab switch No automatic pause before the configured delay
Long tab switch Pause behavior, reconnection time and state restoration
Browser closes or network drops Recovery behavior independent of visibility changes
Deployment or server restart Whether required data survives outside circuit memory
Many hidden tabs Server memory, connection counts and resumed request load

Try real browser families and device profiles. Browsers can throttle background timers, so compare observed behavior with the configured delay. When running multiple replicas, test your production routing and state strategy. If the application uses a shared cache or persistent state, verify its tenancy and privacy boundaries.

Plan what belongs in persisted state

A shopping cart, confirmed payment, or draft that the user expects to reopen should have a lifecycle beyond a SignalR circuit. Save the minimum serializable state necessary to restore a page, and treat restored client state as untrusted until it has been checked against the authenticated user and current permissions.

For observability, measure active connection count and memory under the same number of synthetic users with auto-pause enabled and disabled. A page with many subscribed services or large models is a useful stress case. Keep the load model, sample duration, device/browser mix, and server configuration fixed across runs. The sample was built and its home page and Blazor bootstrap script returned successfully. Hidden-tab transitions and cross-browser memory savings were not measured.

How do pause, reconnect and restart differ?

A connected circuit is associated with the interactive page. A temporary network failure can disconnect the transport even though the browser tab remains visible. The server may retain a disconnected circuit for a period. Auto-pause instead begins with a visibility event and a configured delay. Test those paths separately because they can produce different server and UI observations.

A full page reload can create a new circuit, depending on the application and saved state. A server restart can remove in-memory state regardless of the browser’s visibility. Treat a successful counter restoration after one test as evidence for that exact path. It does not establish durability across every route, browser, and deployment.

Create a test user with a partly completed form. Switch tabs, return before the delay, and confirm the current input. Repeat beyond the threshold. Then close the page and reopen it, and finally restart the server. Record what restores in each case. For any business value that must survive, move it into a deliberate persisted representation and verify ownership before restoring it.

The browser can hide a tab while the user is actively working in another application. Choose a delay that makes it reasonable to come back without interruptions. For a dashboard with an active stream or a form with a long-running request, check whether the application reports progress accurately when the user returns. This is also a useful point to verify keyboard focus and whether any reconnect indication explains what happened.

Deploy to one representative workload first

Try the feature on one Interactive Server application and collect connection counts, server working set, resume latency and application errors. Start with comparable session mixes. An apparent reduction in active connections can simply mean the test submitted less work. Include users who return quickly and users who remain inactive for much longer.

Review the relevant browser resources and their versions when you deploy. A server with the package installed still needs the browser to run the proper client assets. Check the bootstrap script and static asset response codes before changing visibility timing. Confirm that a reverse proxy allows the connection behavior your deployment expects.

FAQ

Does auto-pause apply to Blazor WebAssembly? This workflow is for Interactive Server circuits.

Can I assume a hidden tab resumes with every field intact? Persist business-critical state deliberately and verify the exact resume behavior of your component.

Is ten seconds a production recommendation? It is a test setting. Choose a production delay based on user behavior and measurable resource use.

See ASP.NET Core 11 release notes and the ASP.NET PB IIS hosting guide.

Comments