The AuthorizeView component supports policy-based authorization. You can use the Policy parameter for policy-based authorization.
<AuthorizeView Policy="IsShowContent">
<p>You can only see the content if enabled the IsShowContent policy.</p>
</AuthorizeView>
Policy based authorization in Asp.Net Core
The policies are registered in the application Startup classes ConfigureServices method.
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthorization(config =>
{
config.AddPolicy("IsShowContent", policy => policy.RequireClaim("IsShowContent", "true"));
});
}
Share with