Skip to content

Support using Blazor pages with status code pages middleware #51203

@danroth27

Description

@danroth27

If you try to use Blazor pages with the status code pages middleware you get unexpected behavior.

Repro steps:

  • Create a Blazor Web App with global interactive server rendering
  • Add the status code pages middleware to Program.cs: app.UseStatusCodePagesWithReExecute("/StatusCode/{0}");
  • Add Components/Pages/StatusCode.razor:
@page "/StatusCode/{status:int}"

<PageTitle>@Status</PageTitle>

<h1>@Status</h1>

@code {
    [Parameter]
    public int Status { get; set; }
}
  • Run the app and browser to a non-existent page, like /test

Expected result: Blazor status page renders for the 404 response.
Actual result: Blazor status page shows up briefly and then is replaced with a plain text "Not found" page.

We special case re-executed requests from the error handling middleware. We might need to do this for the status code page middleware as well.

Related issue for handling not found requests: #45654

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pillar: Complete Blazor Webarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing one

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions