Skip to content

Fix Blazor Error page being replaced by NotFound during WebAssembly activation - #69998

Draft
MohamedHasan3644 wants to merge 2 commits into
dotnet:mainfrom
MohamedHasan3644:fix-63842-blazor-error-page-handoff
Draft

MohamedHasan3644 wants to merge 2 commits into
dotnet:mainfrom
MohamedHasan3644:fix-63842-blazor-error-page-handoff

Conversation

@MohamedHasan3644

Copy link
Copy Markdown
Contributor

Description

With global WebAssembly interactivity, navigating directly to /Error initially renders the Error page on the server. When WebAssembly activates, the client router replaces that content with NotFound because the Error component exists only in the server project and is not discoverable in the client assembly.

Global Auto interactivity is also affected when routing runs on WebAssembly.

Changes

  • Generate the Error page in the client project for global WebAssembly and Autoconfigurations, alongside the router and layout.
  • Pass the server's HTTP request identifier to Routes as a serializableparameter instead of requiring HttpContext in the client component.
  • Cascade that identifier only during prerendering. The Error page retains its existing persistent Request ID state so the resolved identifier survives interactive activation.
  • Avoid reusing the original HTTP request identifier when navigating to Error later through the interactive router.
  • Preserve the existing Error page placement and HttpContext-based behavior for static rendering, Server-only interactivity, and per-page configurations.

This keeps the layout interactive rather than excluding the Error route from interactive rendering. No framework router changes are required.

Test coverage

Added BlazorWebTemplate_ErrorPageSurvivesInteractiveActivation with five cases:

  • Global WebAssembly.
  • Global WebAssembly with Activity.Current suppressed to exercise the HTTP TraceIdentifier fallback.
  • Global WebAssembly with Individual authentication.
  • Global Auto.
  • Global Auto with Individual authentication.

Each case exercises both built and published generated applications and verifies:

  • Error content and Request ID before activation.
  • Error content and the same Request ID after activation.
  • Working layout interactivity.
  • Actual WebAssembly rendering on a subsequent Auto visit.
  • Counter interaction and navigation back to Error without a stale HTTP
    Request ID.
  • NotFound behavior and layout interactivity for a genuinely missing route.

Also added global WebAssembly and Auto configurations to the existing BlazorWebTemplate_Works smoke test.

Output

Before fix

63842-without-fix.mp4

After fix

63842-with-fix.mp4

Fixes #63842

@github-actions github-actions Bot added the area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI label Oct 23, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 23, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @MohamedHasan3644. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service
dotnet-policy-service Bot deployed to copilot-pat-pool October 23, 2026 11:15 Active
@dotnet-policy-service
dotnet-policy-service Bot deployed to copilot-pat-pool October 23, 2026 11:16 Active

This branch was successfully deployed

1 active deployment
copilot-pat-pool — a87e810b Deployed Oct 23, 2026 by dotnet-policy-service[bot] via pat_pool #1948
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-commandlinetools Includes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Blazor] SSR Error page gets overwritten by NotFound WASM component on InteractiveWebAssembly handoff

2 participants