Skip to content

Fix NavigationManager.Refresh ignoring forceReload parameter - #68185

Open
ManuelEnzo wants to merge 1 commit into
dotnet:mainfrom
ManuelEnzo:fix-issue-59854-navigationmanager-refresh
Open

Fix NavigationManager.Refresh ignoring forceReload parameter#68185
ManuelEnzo wants to merge 1 commit into
dotnet:mainfrom
ManuelEnzo:fix-issue-59854-navigationmanager-refresh

Conversation

@ManuelEnzo

Copy link
Copy Markdown

Problem

NavigationManager.Refresh(bool forceReload = false) always performed a full
forced page reload, regardless of the forceReload argument passed in:

public virtual void Refresh(bool forceReload = false)
    => NavigateTo(Uri, forceLoad: true, replace: true);

The forceReload parameter was accepted but never used — forceLoad: true
was hardcoded. This contradicts the method's own doc comment, which states
that when forceReload is false the response may be merged with the
existing document to preserve client-side state (enhanced navigation),
falling back to a full reload only if necessary.

This affects any NavigationManager that relies on the base class's default
Refresh implementation (e.g. HttpNavigationManager, used for
non-interactive/static server-side rendering) rather than overriding it.
RemoteNavigationManager (Blazor Server) and WebAssemblyNavigationManager
already forward forceReload correctly through their own overrides, so this
does not affect interactive Blazor Server/WebAssembly circuits.

Fix

Pass forceReload through to NavigateTo's forceLoad option instead of
hardcoding true:

public virtual void Refresh(bool forceReload = false)
    => NavigateTo(Uri, forceLoad: forceReload, replace: true);

Testing

Added three regression tests in NavigationManagerTest.cs covering
Refresh(false), Refresh(true), and the default parameter value, asserting
the ForceLoad option passed to NavigateTo matches the argument.

Ran the full Microsoft.AspNetCore.Components.Tests suite
(eng\build.cmd -test -projects .\src\Components\Components\test\Microsoft.AspNetCore.Components.Tests.csproj):
1278 tests, 1265 passed, 5 failed, 8 skipped. The 5 failures are pre-existing
on a clean checkout of main (unrelated EventCallbackFactoryBinderExtensionsTest
date-formatting tests and one PersistentServicesRegistryTest test, likely
culture-dependent) and are unaffected by this change — confirmed by running
the same suite before applying the fix.

Fixes #59854

Refresh(forceReload) always called NavigateTo with forceLoad: true,
regardless of the forceReload argument, so callers could never opt in
to the enhanced-navigation merge behavior described in the method's
own doc comment.

Pass the forceReload parameter through to NavigateTo's forceLoad
option instead of hardcoding true.

Fixes dotnet#59854
@ManuelEnzo
ManuelEnzo requested a review from a team as a code owner August 3, 2026 19:34
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Aug 3, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @ManuelEnzo. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@ManuelEnzo

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

1 similar comment
@ManuelEnzo

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NavigationManager.Refresh does not make use of optional parameter 'forceReload'

1 participant