Skip to content

Commit 89582f2

Browse files
authored
[Pre4] NavigateTo no longer throws navigation exception (#35431)
1 parent cd190a7 commit 89582f2

File tree

1 file changed

+18
-0
lines changed
  • aspnetcore/release-notes/aspnetcore-10/includes

1 file changed

+18
-0
lines changed

aspnetcore/release-notes/aspnetcore-10/includes/blazor.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,4 +367,22 @@ In Blazor Web Apps, framework static assets are automatically preloaded using [`
367367
368368
For more information, see <xref:blazor/fundamentals/static-files?view=aspnetcore-10.0#preloaded-blazor-framework-static-assets>.
369369
370+
## `NavigationManager.NavigateTo` no longer throws a `NavigationException`
371+
372+
Previously, calling <xref:Microsoft.AspNetCore.Components.NavigationManager.NavigateTo%2A?displayProperty=nameWithType> during static server-side rendering (SSR) would throw a <xref:Microsoft.AspNetCore.Components.NavigationException>, interrupting execution before being converted to a redirection response. This caused confusion during debugging and was inconsistent with interactive rendering, where code after <xref:Microsoft.AspNetCore.Components.NavigationManager.NavigateTo%2A> continues to execute normally.
373+
374+
Calling <xref:Microsoft.AspNetCore.Components.NavigationManager.NavigateTo%2A?displayProperty=nameWithType> during static SSR no longer throws a <xref:Microsoft.AspNetCore.Components.NavigationException>. Instead, it behaves consistently with interactive rendering by performing the navigation without throwing an exception.
375+
376+
Code that relied on <xref:Microsoft.AspNetCore.Components.NavigationException> being thrown should be updated. For example, in the default Blazor Identity UI, the `IdentityRedirectManager` previously threw an <xref:System.InvalidOperationException> after calling `RedirectTo` to ensure it wasn't invoked during interactive rendering. This exception and the [`[DoesNotReturn]` attributes](xref:System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute) should now be removed.
377+
378+
!!!!!!!!! HOLD THE NEXT BIT FOR PREVIEW 5 !!!!!!!!!
379+
To revert to the previous behavior of throwing a <xref:Microsoft.AspNetCore.Components.NavigationException>, set the following <xref:System.AppContext> switch:
380+
381+
```csharp
382+
AppContext.SetSwitch(
383+
"Microsoft.AspNetCore.Components.Endpoints.NavigationManager.EnableThrowNavigationException",
384+
isEnabled: true);
385+
```
386+
!!!!!!!!! HOLD END !!!!!!!!!
387+
370388
-->

0 commit comments

Comments
 (0)