Skip to content

Error boundaries may block redirects by handling exceptions of type NavigationExceptionΒ #52777

@meisam-dehghan

Description

@meisam-dehghan

When you try to navigate to another page by using the NavigationManager.NavigateTo in a blazor web app introduced in .net8,the following exception is thrown :
Microsoft.AspNetCore.Components.NavigationException: 'Exception of type 'Microsoft.AspNetCore.Components.NavigationException' was thrown.'
Even if you put the logic in a try/catch block,the exception would be still thrown and the page would stay on the current route.This means that if,for example,you wanted to create a login page that should take the user to the main page after a successful login form submission,the user would still stay on the login page!

Even though the issue had previously been brought up by @danroth27 at #49143 and closed as done later on,the problem still persists in the final version of .net8.I've also created a sample project that you can check out in the following repo:
Blazor Web App With Custom Cookie-based Authentication

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions