Skip to content

Commit

Permalink
Authentication state updates
Browse files Browse the repository at this point in the history
  • Loading branch information
guardrex committed Sep 19, 2024
1 parent 1658e76 commit e2aebc2
Show file tree
Hide file tree
Showing 7 changed files with 499 additions and 415 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ public HttpContext? Context { get; set; }

The value is `null` during interactive rendering and is only set during static SSR.

In many cases, there are better alternatives than using <xref:Microsoft.AspNetCore.Http.HttpContext>. If you need to know the current URL or to perform a redirection, the APIs on <xref:Microsoft.AspNetCore.Components.NavigationManager> work with all render modes. If you need to know the user's authentication state, use Blazor's <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider> service over using <xref:Microsoft.AspNetCore.Http.HttpContext.User?displayProperty=nameWithType>.
In many cases, there are better alternatives than using <xref:Microsoft.AspNetCore.Http.HttpContext>. If you need to know the current URL or to perform a redirection, the APIs on <xref:Microsoft.AspNetCore.Components.NavigationManager> work with all render modes. If you need to know the user's authentication state, use Blazor's <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider> service ([`AuthenticationStateProvider` documentation](xref:blazor/security/authentication-state)) over using <xref:Microsoft.AspNetCore.Http.HttpContext.User?displayProperty=nameWithType>.
4 changes: 2 additions & 2 deletions aspnetcore/blazor/components/prerendering-and-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,8 @@ By initializing components with the same state used during prerendering, any exp
* [Stateful reconnection after prerendering](xref:blazor/components/lifecycle#stateful-reconnection-after-prerendering): Although the content in the section focuses on Blazor Server and stateful SignalR *reconnection*, the scenario for prerendering in hosted Blazor WebAssembly apps (<xref:Microsoft.AspNetCore.Mvc.Rendering.RenderMode.WebAssemblyPrerendered>) involves similar conditions and approaches to prevent executing developer code twice. To preserve state during the execution of initialization code while prerendering, see *Persist prerendered state* section of this article.
* [Prerendering with JavaScript interop](xref:blazor/components/lifecycle#prerendering-with-javascript-interop)
* Authentication and authorization subjects that pertain to prerendering
* [General aspects](xref:blazor/security/index#aspnet-core-blazor-authentication-and-authorization)
* [Prerendering with authentication](xref:blazor/security/webassembly/additional-scenarios#prerendering-with-authentication)
* [General aspects](xref:blazor/security/index)
* [Prerendering with authentication in hosted Blazor WebAssembly apps](xref:blazor/security/webassembly/additional-scenarios#prerendering-with-authentication)
* [Host and deploy: Blazor WebAssembly](xref:blazor/host-and-deploy/webassembly)
* [Handle errors: Prerendering](xref:blazor/fundamentals/handle-errors#prerendering)
* <xref:Microsoft.AspNetCore.Components.Routing.Router.OnNavigateAsync> is executed *twice* when prerendering: [Handle asynchronous navigation events with `OnNavigateAsync`](xref:blazor/fundamentals/routing#handle-asynchronous-navigation-events-with-onnavigateasync)
Expand Down
Loading

0 comments on commit e2aebc2

Please sign in to comment.