Skip to content

Blazor Router NotFound page doesn't redirect to notfound page #64653

@Schoof-T

Description

@Schoof-T

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a Blazor InteractiveServer .NET 10 project, and I added NotFoundPage="typeof(Pages.NotFound)" to the Routes.razor page.

I also have a NotFound.razor page.

@page "/not-found"
@layout MainLayout

<h3>Not Found</h3>
<p>Sorry, the content you are looking for does not exist.</p>

When I navigate to an unkown URL, I just get the default not found page.

Image

Expected Behavior

I expect the NotFound page to be rendered when I navigate to an unkown page.

Steps To Reproduce

  • Add NotFoundPage="typeof(Pages.NotFound)" to the Routes.razor page.
<Router AppAssembly="typeof(Program).Assembly" NotFoundPage="typeof(Pages.NotFound)">
    <Found Context="routeData">
        <RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
        <FocusOnNavigate RouteData="routeData" Selector="h1" />
    </Found>
</Router>
  • Create a NotFound.Razor page
@page "/not-found"
@layout MainLayout

<h3>Not Found</h3>
<p>Sorry, the content you are looking for does not exist.</p>

Exceptions (if any)

No response

.NET Version

10

Anything else?

Blazor InteractiveServer

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions