Skip to content

NotFound page doesn't get rendered if NavigationManager.NotFound() is called from an async method #62469

@danroth27

Description

@danroth27

Repro steps:

  • Install .NET 10 Preview 6 (10.0.100-preview.6.25321.102)
  • Create a default Blazor Web App
  • Update Home.razor with:
@page "/"  
@inject NavigationManager NavigationManager

<PageTitle>Home</PageTitle>  

<h1>Hello, world!</h1>  

Welcome to your new app.  


@code {
    [SupplyParameterFromQuery]  
    public string? Id { get; set; }  

    protected override async Task OnInitializedAsync()  
    {
        await Task.Delay(1000);
        if (!string.IsNullOrEmpty(Id))  
        {
            NavigationManager.NotFound();
        }  
    }  
}
  • Run the app and browse to /?id=123

Expected result: NotFound page rendered with a 404 status code
Actual result: Home page is rendered with a 404 status code

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Components

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions