[release/8.0-rc1] [Blazor] Add APIs for "enhanced refresh" #50124
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #50068 to release/8.0-rc1
/cc @MackinnonBuck
[Blazor] Add APIs for "enhanced refresh"
Adds
NavigationManager.Refresh(bool forceReload = false)
. This allows developers to refresh statically rendered content by forcing an SSR update.Description
If
forceReload
istrue
, a full page reload will always be performed. Otherwise, the response HTML may be merged with the document's existing HTML to preserve client-side state, falling back on a full page reload if necessary.Fixes #49414
Customer Impact
Unlike Blazor Server or WebAssembly components, statically rendered Blazor components don't update their content after being added to the page. However, the developer might want to manually trigger a refresh of static page content without performing a full page reload, which would destroy all client-side state.
An example of when this is useful might be if the user's authentication state changes, so the statically rendered layout needs to updated accordingly.
The alternative to using this method would be to call
NavigationManager.NavigateTo(NavigationManager.Uri, replace: true)
. However, this has its downsides:The new
Refresh
method overcomes both these downsides.Regression?
Risk
This is an additive feature and won't affect existing app functionality.
Verification
Packaging changes reviewed?