如果用户尝试访问授权页面,我想将未经授权的用户重定向到登录页面。到目前为止,我是使用本教程编写的。项目建设成功。但是浏览器抛出了这个错误
未处理的异常呈现组件:在“窗口”中找不到“AuthenticationService”
页面卡在授权上
<Authorizing>
<div class="main">Please wait...</div>
</Authorizing>
Run Code Online (Sandbox Code Playgroud)
所有页面都打印“请稍候...” 我该如何解决这个错误?
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
<RedirectToLogin />
</NotAuthorized>
<Authorizing>
<div class="main">Please wait...</div>
</Authorizing>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
Run Code Online (Sandbox Code Playgroud)
@using System.Net.Http
@using System.Net.Http.Json
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using Kermes.Client
@using Kermes.Client.Shared
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@using Blazorise
Run Code Online (Sandbox Code Playgroud)
public class Program
{
public static async Task …Run Code Online (Sandbox Code Playgroud)