The Router component, in conjunction with the AuthorizeRouteView component, allows the app to specify custom content if:
- The user fails an
[Authorize]
condition applied to the component. The markup of the<NotAuthorized>
element is displayed. The[Authorize]
attribute is covered in the[Authorize]
attribute section. - Asynchronous authorization is in progress, which usually means that the process of authenticating the user is in progress. The markup of the
<Authorizing>
element is displayed. - Content isn’t found. The markup of the
<NotFound>
element is displayed.
<CascadingAuthenticationState> <Router AppAssembly="@typeof(Program).Assembly"> <Found Context="routeData"> <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"> <NotAuthorized> <h1>Sorry</h1> <p>You're not authorized to reach this page.</p> <p>You may need to log in as a different user.</p> </NotAuthorized> <Authorizing> <h1>Authorization in progress</h1> <p>Only visible while authorization is in progress.</p> </Authorizing> </AuthorizeRouteView> </Found> <NotFound> <LayoutView Layout="@typeof(MainLayout)"> <h1>Sorry</h1> <p>Sorry, there's nothing at this address.</p> </LayoutView> </NotFound> </Router> </CascadingAuthenticationState>