【发布时间】:2021-01-31 13:46:43
【问题描述】:
在 Blazor WebAssembly 中,如何为已登录用户和未登录用户提供单独的布局?
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<Authorizing>
<text> Authotizing ...</text>
</Authorizing>
</AuthorizeRouteView>
/*Something like this:*/
<NotAuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(NotAuthorizedLayout)">
<Authorizing>
<text> Authotizing ...</text>
</Authorizing>
<NotAuthorized>
<text></text>
</NotAuthorized>
</NotAuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
或者换句话说,如何在 Blazor 中的不同布局之间切换?
【问题讨论】:
标签: c# asp.net-core blazor blazor-webassembly