Live Chat Icon For mobile
Live Chat Icon

How can I implement policy based authorization in Blazor?

Platform: Blazor| Category: General

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>

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

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.