Working with authentication
The CascadingAuthenticationState
component and the AuthorizeRouteView
component work together to make authentication simpler. The CascadingAuthenticationState
component is responsible for cascading the user’s authentication state to all its descendants. It is typically used to wrap the Router
component.
In the following example, the App
component relies on the CascadingAuthenticationState
component to provide the user’s authentication state to all the routable components:
IMPORTANT NOTE
Sometimes we refer to routable components as pages.
App.razor
@inject NavigationManager Navigation
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(App).Assembly">
<Found Context="routeData">
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">...