[release/10.0-preview7] [Blazor] Support persisting component state on enhanced navigation #62846
+3,078
−1,082
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 #62824 to release/10.0-preview7
/cc @javiercn
[Blazor] Support persisting component state on enhanced navigation
Adds support for restoring data from persistent component state during enhanced navigation requests.
Description
Currently, the persistent state only works during the initial render of components for a given runtime. This limitation exists because the system doesn't recognize enhanced navigations and lacks a mechanism to update the state of already running components.
This fix adds a mechanism to opt-in to receive state updates from enhanced navigations coming from the server to running Blazor server and webassembly runtimes.
Fixes #51584
Customer Impact
Customers experience inconsistent behavior and confusion when using PersistentComponentState with Blazor’s enhanced navigation.
They encounter bugs such as double database queries and unpredictable initialization, leading to degraded user experience—especially flickering and repeated API calls instead of preserved state.
Workarounds require extra boilerplate, increase page size, and do not scale well for complex scenarios. Some developers avoid enhanced navigation or restructure their applications in less optimal ways to mitigate these issues.
Regression?
Risk
[Justify the selection above]
Verification
Packaging changes reviewed?