Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] Reconcile NavigationManager behavior #59451

Open
javiercn opened this issue Dec 12, 2024 · 1 comment
Open

[Blazor] Reconcile NavigationManager behavior #59451

javiercn opened this issue Dec 12, 2024 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components

Comments

@javiercn
Copy link
Member

The behavior NavigationManager exhibits is different in SSR rendering than it is on other interactive modes. In particular, SSR relies on throwing an exception that gets captured by the framework to convert the error into a redirect.

This behavior leads to a poor user experience where users debugging their apps typically see the debugger break when this exception is thrown and incorrectly believe that there is an error/bug on the framework.

In addition to this, code that exists after a call to NavigateTo will continue to execute on interactive render modes but will abruptly stop in SSR scenarios.

The solution for this involves a breaking change, but the number of issues that the current behavior produces justifies such change. We should stop throwing an exception during SSR and instead signal the underlying renderer that a redirection has been requested. We should continue to execute the current ongoing synchronous render batch until completion and, once it finishes, we should dispose the existing renderer and trigger the redirect. This will align the behavior with what happens in other platforms, but we should also have a suite of tests that capture these behaviors across render modes to ensure a consistent experience.

For backcompat reasons we will include an AppContext switch that will continue to throw the exception in case someone needs it.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Dec 12, 2024
@javiercn
Copy link
Member Author

Related issue #53996

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

No branches or pull requests

1 participant