QuickDevGuide

Home › Blazor

Authentication & Authorization — Blazor

Blazor builds on ASP.NET Core auth (cookies, OpenID Connect, Entra ID, Identity). Tool Use [Authorize] / @attribute [Authorize(Roles = "Admin")] protect a routable page <AuthorizeView> with <Authorized> / <NotAuthorized> show/hide UI parts <AuthorizeView Policy="CanEditOrders"> policy-based UI [CascadingParameter] Task<AuthenticationState> read the user in code AuthenticationStateProvider the source of the current user AddCascadingAuthenticationState() makes auth state available everywhere The .NET 8+ template with "Individual Accounts" scaffolds ASP.NET Core Identity pages as Razor components. Hiding a button is not security. Always re-check authorisation in the service/API that performs the action — especially in WebAssembly, where the client can be modified.

Key Takeaways