Skip to content

Flip switch for controlling navigation flow on SSR #62358

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

Merged
merged 9 commits into from
Jun 17, 2025

Conversation

ilonatommy
Copy link
Member

@ilonatommy ilonatommy commented Jun 16, 2025

Navigation with NavigationException stays the default behavior for SSR navigation

Switch was introduced in #61306. The PR unifies the navigation across render modes but also allows SSR code after the navigation to run. Upgrading the application could lead to unexpected behaviors, e.g. see how templates had to be changed to adjust to the new navigation: #62105. From this reason, we decided to keep the default behavior for the exception flow. It can be changed by setting Microsoft.AspNetCore.Components.Endpoints.NavigationManager.DisableThrowNavigationException switch. New projects will use the new way of working.

Description

This PR:

  • renames the switch EnableThrowNavigationException -> DisableThrowNavigationException,
  • uses DisableThrowNavigationException: false by default,
  • adjusts tests accordingly,
  • sets DisableThrowNavigationException: true in the templates.

@ilonatommy ilonatommy requested review from wtgodbe and a team as code owners June 16, 2025 07:12
@ilonatommy ilonatommy added this to the 10.0-preview6 milestone Jun 16, 2025
@ilonatommy ilonatommy added the area-blazor Includes: Blazor, Razor Components label Jun 16, 2025
@ilonatommy ilonatommy self-assigned this Jun 16, 2025
@ilonatommy ilonatommy requested review from Copilot and removed request for a team and wtgodbe June 16, 2025 07:29
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR renames the navigation exception switch and updates its usage across the codebase to support a unified navigation flow for SSR while allowing SSR code to run after navigation. Key changes include renaming the switch from EnableThrowNavigationException to DisableThrowNavigationException, updating test logic with the new inverted parameter, and modifying the navigation manager implementations accordingly.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/submodules/googletest Updated subproject commit hash
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/Program.cs Set the new switch to true for templates
src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/Program.Main.cs Set the new switch to true for templates
src/Components/test/E2ETest/ServerRenderingTests/NoInteractivityTest.cs Inverted switch logic in tests
src/Components/test/E2ETest/ServerRenderingTests/InteractivityTest.cs Inverted switch logic in tests
src/Components/Server/src/Circuits/RemoteNavigationManager.cs Updated constant name and switch logic for remote navigation
src/Components/Endpoints/test/EndpointHtmlRendererTest.cs Inverted switch logic in endpoint tests
src/Components/Endpoints/src/DependencyInjection/HttpNavigationManager.cs Updated constant name and switch logic for HTTP navigation

@ilonatommy ilonatommy requested review from javiercn and danroth27 June 16, 2025 07:37
@build-analysis build-analysis bot mentioned this pull request Jun 16, 2025
3 tasks
Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once we put the flag in the csproj files and undo the submodule update change!

akoeplinger pushed a commit to dotnet/sdk that referenced this pull request Jun 16, 2025
For dotnet/aspnetcore#62358.

Defines a switch that can be controlled by `BlazorDisableThrowNavigationException` property.
@ilonatommy ilonatommy enabled auto-merge (squash) June 16, 2025 13:48
@ilonatommy ilonatommy disabled auto-merge June 16, 2025 13:49
@ilonatommy ilonatommy enabled auto-merge (squash) June 16, 2025 15:30
@ilonatommy ilonatommy merged commit f46b5da into dotnet:main Jun 17, 2025
27 checks passed
@ilonatommy
Copy link
Member Author

/backport to release/10.0-preview6

Copy link
Contributor

Started backporting to release/10.0-preview6: https://github.com/dotnet/aspnetcore/actions/runs/15709205261

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

Successfully merging this pull request may close these issues.

2 participants