Skip to content

[Blazor] Support state in NavigationManager #42534

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
Jul 8, 2022

Conversation

javiercn
Copy link
Member

@javiercn javiercn commented Jul 1, 2022

Fixes #42617

Adds support for passing state during navigations via navigation manager and updates the authentication infrastructure to make use of it.

The previous authentication infrastructure implementation used JS interop and sessionStorage and the URL query string to pass data between authentication states.

This was brittle and required extra work to avoid things like CSRF logouts or to encode/decode error messages on the error UI states.

The new NavigationManager API simplifies associating a state that is associated with the navigation entry and not with the session (like sessionStorage) and allows simple communication between different pages with the benefit that there is no cleanup needed.

Part of the improvements on the auth system are going to rely on this to pass data from other pages to the authentication pages, but since this change is general purpose and a net positive, I separated it into its own PR.

@javiercn javiercn requested review from a team as code owners July 1, 2022 16:49
@ghost ghost added the area-blazor Includes: Blazor, Razor Components label Jul 1, 2022
@javiercn javiercn force-pushed the javiercn/add-support-for-history-state branch from 0ee7fd6 to 6aa5aab Compare July 6, 2022 12:10
@javiercn javiercn changed the title [Blazor][Prototype] Support state in NavigationManager [Blazor] Support state in NavigationManager Jul 6, 2022
@javiercn javiercn added the api-approved API was approved in API review, it can be implemented label Jul 8, 2022
@javiercn javiercn enabled auto-merge (squash) July 8, 2022 10:32
Copy link
Member

@SteveSandersonMS SteveSandersonMS left a comment

Choose a reason for hiding this comment

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

Nice!

I know it would be annoying to go through CI all over again just to change one XML doc, so I totally understand if you prefer not to block this PR on it. If you wouldn't mind making that small tweak in your follow-up PR for auth, that would be great.

@javiercn
Copy link
Member Author

javiercn commented Jul 8, 2022

I know it would be annoying to go through CI all over again just to change one XML doc, so I totally understand if you prefer not to block this PR on it. If you wouldn't mind making that small tweak in your follow-up PR for auth, that would be great.

It's ok, I had to update the JS files which I forgot after the rename, so I have updated the remarks to bring it inline with what the remarks on other properties mention.

@javiercn javiercn merged commit 0e255c5 into main Jul 8, 2022
@javiercn javiercn deleted the javiercn/add-support-for-history-state branch July 8, 2022 16:24
@ghost ghost added this to the 7.0-preview7 milestone Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Blazor] Support state within NavigationManager
5 participants