Skip to content

NavigationManager doesn't navigate relative to the base address when using Blazor SSR #49670

@danroth27

Description

@danroth27

According to the docs, NavigationManager.NavigateTo should treat relative URIs as relative to the base URI, which it how it works with existing Blazor Server and Blazor WebAssembly apps. But with SSR, it seems to navigate relative to the current address instead.

Repro steps:

  • Create a Blazor Web App
  • Update Index.razor with the following:
@page "/"
@page "/foo"
@page "/foo/bar"
@inject NavigationManager NavigationManager

<PageTitle>Index</PageTitle>

<h1>Hello, world!</h1>

Welcome to your new app.

@code {
    protected override void OnInitialized()
    {
        NavigationManager.NavigateTo("weather");
    }
}
  • Browse to "/foo/bar"

Expected result: Request is redirected to /weather
Actual result: Request is redirected to /foo/weather

Metadata

Metadata

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions