Skip to content

[release/11.0] Fix Blazor browser option handling - #70877

Open
kotlarmilos wants to merge 1 commit into
dotnet:release/11.0from
kotlarmilos:backport/pr-70526-to-release/11.0
Open

kotlarmilos wants to merge 1 commit into
dotnet:release/11.0from
kotlarmilos:backport/pr-70526-to-release/11.0

Conversation

@kotlarmilos

Copy link
Copy Markdown
Member

Backport of #70526 to release/11.0

/cc @ilonatommy @dariatiurina

Fix Blazor browser option handling

Fix five server-configured browser option issues.

Description

Backports #70526, which fixes the five WithBrowserOptions problems reported in #70510. The circuit inactivity timeout is read when circuit disposal is scheduled instead of being captured during boot. The server-configured WebAssembly culture is forwarded before the runtime loads, and an explicit JavaScript culture still takes precedence. PreserveDom = false now disables enhanced navigation for links and forms and replaces streamed and enhanced POST content, and a GET that first supplies the setting falls back to a full page load. The server log level is applied unless startup or an initializer sets the circuit log level explicitly. Reconnection retry intervals shorter than one second now take effect.

The production changes apply without conflicts. Conflicts in BrowserConfigurationTest.cs and RazorComponentEndpointsStartup.cs were resolved by omitting the EnvironmentName test setup and assertions from #69702, which is not in release/11.0.

Fixes #70510

Customer Impact

Applications that configure these options through WithBrowserOptions in .NET 11 do not get the documented behavior, and no error is reported. The circuit inactivity timeout, WebAssembly culture, DOM preservation setting, and circuit log level are ignored, and short reconnection intervals are not honored. The behavior is documented in dotnet/AspNetCore.Docs#38107. The workaround is to set the equivalent values in JavaScript startup options.

Regression?

  • Yes
  • No

WithBrowserOptions is new in .NET 11.

Risk

  • High
  • Medium
  • Low

The change spans the Blazor boot, enhanced navigation, streaming, and reconnection code paths. Applications on 11.0 that already set PreserveDom = false currently keep enhanced navigation and will instead get full page loads and DOM replacement after this change, which matches the documented behavior but is an observable change. The other four fixes only take effect when the corresponding option is configured, and explicit JavaScript or initializer values keep precedence over server configuration.

Verification

  • Manual (required)
  • Automated

#70526 adds E2E and unit coverage for each option, and this backport carries those tests.

Packaging changes reviewed?

  • Yes
  • No
  • N/A

No packaging configuration files are changed.

Backport of dotnet#70526. Conflicts in BrowserConfigurationTest.cs and
RazorComponentEndpointsStartup.cs were resolved by omitting the
EnvironmentName test setup from dotnet#69702, which is not in release/11.0.

(cherry picked from commit 470b55a)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c1867eae-0e07-41b2-84d8-6ec25ce71a8c
@kotlarmilos
kotlarmilos requested a review from a team as a code owner November 27, 2026 11:44
@kotlarmilos kotlarmilos added this to the 11.0.x milestone Nov 27, 2026
Copilot AI balanced review requested due to automatic review settings November 27, 2026 11:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

For GET responses with PreserveDom = false, placing the temporary ? inside the URL fragment can prevent a document reload and leave the previous page displayed at the destination URL.

1 open issue
What changed in this PR

Backports #70526 to release/11.0 to address five Blazor browser-option issues reported in #70510, covering configuration timing, precedence, navigation, and reconnection.

Changes:

  • Applies server-configured inactivity timeout, WebAssembly culture, circuit logging, and sub-second retry intervals while preserving explicit JavaScript overrides.
  • Honors disabled DOM preservation during navigation, streaming, and enhanced form submissions.
  • Adds browser and unit coverage, emits configuration for static content, and isolates browser options per request.
File Description
src/​Components/​Web.JS/​src/​Services/​WebRootComponentManager.ts Reads the current inactivity timeout when scheduling disposal.
src/​Components/​Web.JS/​src/​Services/​NavigationEnhancement.ts Honors disabled DOM preservation and adds full-load fallback.
src/​Components/​Web.JS/​src/​Services/​ComponentDescriptorDiscovery.ts Adds culture to WebAssembly server options.
src/​Components/​Web.JS/​src/​Rendering/​StreamingRendering.ts Applies current browser options before streamed updates.
src/​Components/​Web.JS/​src/​Rendering/​DomMerging/​DomSync.ts Supports replacement without preserving existing nodes.
src/​Components/​Web.JS/​src/​Platform/​Circuits/​DefaultReconnectionHandler.ts Allows retry delays shorter than one second.
src/​Components/​Web.JS/​src/​Boot.WebAssembly.Common.ts Forwards server culture before runtime loading.
src/​Components/​Web.JS/​src/​Boot.Web.ts Coordinates configuration timing and explicit-option precedence.
src/​Components/​test/​testassets/​Components.WasmMinimal/​Program.cs Allows culture tests to bypass the fixed test culture.
src/​Components/​test/​testassets/​Components.WasmMinimal/​Pages/​BrowserConfigurationEnvVars.razor Displays the current application culture.
src/​Components/​test/​testassets/​Components.TestServer/​wwwroot/​Components.TestServer.lib.module.js Adds initializer override scenarios.
src/​Components/​test/​testassets/​Components.TestServer/​RazorComponents/​Pages/​Forms/​StreamingRenderingForm.razor Adds POST replacement and submission-count test support.
src/​Components/​test/​testassets/​Components.TestServer/​RazorComponents/​GlobalInteractivityApp.razor Accepts a JavaScript culture override for tests.
src/​Components/​test/​testassets/​Components.TestServer/​RazorComponents/​Components/​InteractiveStreamingRenderingComponent.razor Supplies browser options during streaming scenarios.
src/​Components/​test/​testassets/​Components.TestServer/​RazorComponents/​App.razor Leaves DOM preservation unspecified unless explicitly disabled.
src/​Components/​test/​testassets/​Components.TestServer/​RazorComponentEndpointsStartup.cs Configures browser options for test fixtures.
src/​Components/​test/​E2ETest/​Tests/​ServerBrowserConfigurationTest.cs Adds server-option and initializer-precedence browser coverage.
src/​Components/​test/​E2ETest/​Tests/​BrowserConfigurationTest.cs Tests server culture and JavaScript override precedence.
src/​Components/​test/​E2ETest/​ServerRenderingTests/​StreamingRenderingTest.cs Allows configuration comments before streamed content.
src/​Components/​Endpoints/​test/​RazorComponentEndpointInvokerTest.cs Registers the host environment required by configuration emission.
src/​Components/​Endpoints/​test/​BrowserOptionsTest.cs Tests metadata copying and request isolation.
src/​Components/​Endpoints/​src/​Rendering/​EndpointHtmlRenderer.Streaming.cs Supports initial configuration emission before later interactive content.
src/​Components/​Endpoints/​src/​RazorComponentEndpointInvoker.cs Emits browser configuration with initial content.
src/​Components/​Endpoints/​src/​BrowserConfiguration/​BrowserOptions.cs Copies shared endpoint options into request-local state.

Review effort: Balanced

if (warn) {
console.warn(`Enhanced navigation failed for destination ${internalDestinationHref}. Falling back to full page load.`);
}
history.replaceState(null, '', internalDestinationHref + '?');
@PureWeen

Copy link
Copy Markdown
Member

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Source-only review of 19a03eb1475cebb9dcd5e45677b44b64c4e85539: one new finding. The full-load fallback can replace the failing URL when a streamed Not Found page asks not to preserve the DOM. The inline comment proposes using in-place replacement for this URL-preserving fetch.

Existing feedback: The frozen fragment-handling comment covers a separate case in the same fallback helper and was not repeated. Feedback posted after bundle preparation was not available.

Unresolved: Whether subsequent frames from the enhanced response can update the outgoing document while the replacement navigation is pending. The response reader continues after the fallback callback returns, but the visible effect depends on browser timing and matching streaming markers.

DISCARDED
  • Circuit logging and reconnection settings not changing on an already running circuit: the verified consumers take startup options; the source did not establish a live-reconfiguration contract.

Provenance and test boundary: Reviewed the ready v2 bundle (producer 72dfe95c0577acb66ca3c4c925374dfecf64bdcbbe00dbb18de427c4dffb43f9), including its frozen diff, changed-file list, and source roles. The merge base and release/11.0 base tip were both 03b2d69fac550cfb1f9307936fcdcdd691d11469. The base streamed Not Found tests establish the URL behavior; no build, browser test, or target code was run. Vulnerability assessment and unexported content were outside scope.

Generated by ASP.NET Core Pull Request Review for #70877 · copilot · gpt62 · 35.9 AIC · ⌖ 5.12 AIC · ⊞ 10.2K
Comment /review to run again

synchronizeDomContent(document, parsedHtml);
if (navigationEnhancementCallbacks.isDomPreservationDisabled()) {
if (isGetRequest) {
retryEnhancedNavAsFullPageLoad(internalDestinationHref, /* warn */ false);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Medium — Preserve the original URL when rendering a streamed Not Found page. A streamed NavigationManager.NotFound() fetches the configured Not Found page with changeUrl: false, so the failing URL stays in the address bar. If the Not Found response itself supplies PreserveDom = false (for example, via <ConfigureBrowser> on a custom Not Found page), this branch still calls history.replaceState and location.replace through the full-load helper. The browser navigates through the opaque redirect to the Not Found page's route, replacing the failing URL in history. Gate the full-load fallback on changeUrl as well as isGetRequest, and use the in-place replacement path when the fetch must keep the original URL. Add a streamed Not Found regression test that checks both the rendered content and the address bar.

@oroztocil

Copy link
Copy Markdown
Member

The two regressions flagged by copilot here should - if they are real - be fixed on main before we continue with the backport.

This branch has not been deployed

No deployments
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.

4 participants