当我使用
@attribute [Authorize]
Run Code Online (Sandbox Code Playgroud)
在 blazor 客户端应用程序的剃刀页面上,它给了我这个错误
System.InvalidOperationException:无法为“Microsoft.AspNetCore.Components.PageDisplay+AuthorizeViewWithSuppliedData”类型的属性“AuthorizationPolicyProvider”提供值。没有“Microsoft.AspNetCore.Authorization.IAuthorizationPolicyProvider”类型的注册服务
我AuthenticationStateProvider为客户端设置了身份验证并使用自定义如下
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<AuthenticationStateProvider, ApiAuthenticationStateProvider>();
services.AddSingleton<AuthService, AuthService>();
services.AddBlazoredLocalStorage();
}
public void Configure(IComponentsApplicationBuilder app)
{
app.AddComponent<App>("app");
}
}
Run Code Online (Sandbox Code Playgroud)
对这个问题的任何帮助