Asp.net core 为什么应用程序中无法识别NotAuthorizedContent标记
我正在使用app.razor中的标记在所有页面中指示用户无权显示相同消息,但NotAuthorizedContent标记无法识别我Asp.net core 为什么应用程序中无法识别NotAuthorizedContent标记,asp.net-core,razor,blazor,Asp.net Core,Razor,Blazor,我正在使用app.razor中的标记在所有页面中指示用户无权显示相同消息,但NotAuthorizedContent标记无法识别我 <CascadingAuthenticationState> <Router AppAssembly="@typeof(Program).Assembly"> <Found Context="routeData"> <RouteView RouteData=&q
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
<NotAuthorizedContent>
<h1>Sorry</h1>
<p>You're not authorized to reach this page. You may need to log in as a different user.</p>
</NotAuthorizedContent>
</Router>
对不起,这个地址什么也没有
很抱歉
您无权访问此页面。您可能需要以其他用户身份登录
使用authorizedRouteView
:
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
else
{
<p>@L["NotAuthorized"]</p>
}
</NotAuthorized>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>@L["NothingAtAddress"]</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
@如果(!context.User.Identity.IsAuthenticated)
{
}
其他的
{
@L[“未授权”]
}
@L[“不穿礼服”]
注意:我使用的是显示文本的本地化服务。perfect为我提供了您无权访问此页面