Skip to content

NavigateTo doesn't work in Blazor 8 RC2 when enhanced navigation is disabled #51636

@Eirenarch

Description

@Eirenarch

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When enhanced navigation is disabled NavigationManager.NavigateTo doesn't seem to work. It changes the URL but does not navigate in the Blazor Web App model (i.e. with no interactive router, I have not tested with interactive router).

Expected Behavior

NavigateTo should navigate to a new page

Steps To Reproduce

Create a new project Blazor Web App project with .NET 8 RC2 using the default template with example pages and so on. On the counter age add a button to navigate to the weather page

@page "/counter"
@rendermode RenderMode.InteractiveWebAssembly
@inject NavigationManager NavigationManager

<PageTitle>Counter</PageTitle>

<h1>Counter</h1>

<p role="status">Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

<button class="btn btn-primary" @onclick="Navigate">Navigate</button>
@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++;
    }

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

Go to the counter page and navigate. Navigation works as expected. Now disable enhanced navigation in the App.razor

<script src="_framework/blazor.web.js" autostart="false"></script>
<script>
    Blazor.start({
        ssr: { disableDomPreservation: true }
    });
</script>

Try navigating again. Navigation doesn't work anymore. Doesn't work in either Server or Web Assembly mode

.NET Version

8.0.100-rc.2.23502.2

Metadata

Metadata

Labels

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

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions