Skip to content

NavigationManager.NavigateTo has no effect if called after a aynchronous method in OnIntializedAsync, in SSR mode #62519

@SebastianToet

Description

@SebastianToet

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Since .NET 10 Preview 4, where NavigationManager.NavigateTo no longer throws a NavigationException, NavigateTo no longer has any effect in SSR mode, if called after an aynchronous method call in OnInitializedAsync.

Expected Behavior

NavigationManager.NavigateTo navigates to the specified route.

Steps To Reproduce

Doesn't work:

@inject NavigationManager NavigationManager
@code {
    protected override async Task OnInitializedAsync()  
    {
           await Task.Delay(1000);
           NavigationManager.NavigateTo("any-route"); //Does nothing
    }  
}

Works correctly:

@inject NavigationManager NavigationManager
@code {
    protected override async Task OnInitializedAsync()  
    {
           NavigationManager.NavigateTo("any-route"); //Works correctly
           await Tasl.Delay(1000);
    }  

Exceptions (if any)

No response

.NET Version

10.0.100-preview.5.25277.114

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Needs: Author FeedbackThe author of this issue needs to respond in order for us to continue investigating this issue.Needs: ReproIndicates that the team needs a repro project to continue the investigation on this issueStatus: No Recent Activityarea-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions