Skip to content

NavigationManager Issue In Interactive Component When Enhanced Navigation Disabled #64527

@sbwalker

Description

@sbwalker

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When developing a Blazor Web App (SSR) with Enhanced Navigation disabled and using NavigationManager.NavigateTo() from within an Interactive component, Blazor will not render the UI for the specified path. The browser Url will be updated to reflect the path specified in the NavigateTo() method, however the UI will not change.

Image

Expected Behavior

When developing a Blazor Web Application (SSR) with Enhanced Navigation disabled and using NavigationManager.NavigateTo() from within an Interactive component, the system should render the UI for the path specified.

Steps To Reproduce

Create a Blazor Web App using the standard template:

Image

Modify App.razor to disable Enhanced Navigation:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <base href="/" />
    <ResourcePreloader />
    <link rel="stylesheet" href="@Assets["lib/bootstrap/dist/css/bootstrap.min.css"]" />
    <link rel="stylesheet" href="@Assets["app.css"]" />
    <link rel="stylesheet" href="@Assets["BlazorApp32.styles.css"]" />
    <ImportMap />
    <link rel="icon" type="image/png" href="favicon.png" />
    <HeadOutlet />
</head>

<body>
    <Routes />
    <ReconnectModal />
    <script src="@Assets["_framework/blazor.web.js"]" autostart="false"></script>
    <script>
        Blazor.start({
          ssr: { disableDomPreservation: true }
        });
    </script>
</body>

</html>

Modify Home.razor to be an InteractiveServer component and add a button which calls NavigationManager.NavigateTo():

@page "/"
@inject NavigationManager NavigationManager
@rendermode InteractiveServer

<PageTitle>Home</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

<br /><br />

<button class="btn btn-primary" @onclick="NavigateTo">Navigate To Weather</button>

<br /><br />

<a href="/weather">Link To Weather</a>

@code {
    private void NavigateTo()
    {
        NavigationManager.NavigateTo("/weather");
    }
}

Run the application, click the "Navigate To Weather" button - the browser Url will be updated to reflect the path specified in the NavigateTo() method, however the UI will not change.

Exceptions (if any)

No exception is raised, no message is logged in browser console

.NET Version

10.0.0 (same problem exists in .NET 9)

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions