Setup Account confirmation and password recovery in ASP.NET Core

Setup SendGrid Account Setup account at https://sendgrid.com/ Get API key. NuGet and install SendGrid to app. Blazor WebAssembly Setup Note: Add to “Server” project, not “Client” project. Need to setup user secrete for the application first. Add “SendGridUser” and “SendGridKey” user secrete to Server project. secrets.json Add classes to Services folder AuthMessageSenderOptions.cs EmailSender.cs Areas.Identity.Pages.Account.RegisterConfirmation page... » read more

Setting up Certificate for IdentityServer4 in Azure App Service

Error: Publishing a new Blazor app with Identity to Azure App Service giving the following error: HTTP ERROR 500 Fix: Steps: Windows PowerShell (Admin mode) Manage computer certificates Certificates – Local Computer -> Personal -> Certificates Right click on certificate -> Export Enable Password and select “TripleDES-SHA1” Upload pfx file to Azure App Service Get... » read more

AuthenticationStateProvider vs AuthenticationState

AuthenticationStateProvider AuthenticationState AuthenticationStateProvider vs AuthenticationState Blazor has a built-in service called AuthenticationStateProvider service. This service obtains authentication state data from ASP.NET Core’s HttpContext.User. This is how authentication state integrates with existing ASP.NET Core authentication mechanisms. It is this service that is used by AuthorizeView component and CascadingAuthenticationState component to get the authentication state. Don’t use AuthenticationStateProvider directly. Use the AuthorizeView component. The main drawback to using AuthenticationStateProvider directly... » read more

Custom Identity Claim in Blazor

1. Create new field of string type in the AspNetUsers table of Identity database. 2. Add field to ApplicationUser class. (Server) 3. Create new class called CustomUserClaimsPrincipalFactory 4. Add to ConfigureServices in Startup.cs (Server) Note: As soon as the line .AddClaimsPrincipalFactory<CustomUserClaimsPrincipalFactory>(); is added, role does not work anymore.

Secure an ASP.NET Core Blazor WebAssembly hosted app with Identity Server

Note: Need to configure both .Client and .Server projects. .Client Create a new class called CustomUserFactory.cs Add to Main of Program.cs (Client) .Server Add to ConfigureServices of Startup.cs (Server) Result Index.razor (Client) OrgAdminOnly.razor (Client) Sources: https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-identity-server?view=aspnetcore-3.1&tabs=visual-studio

Store does not implement IUserRoleStore

When configuring Blazor Identity … Error: NotSupportedException: Store does not implement IUserRoleStore<TUser>. var roles = await _signInManager.UserManager.GetRolesAsync(user); Fix: Add .AddRoles<IdentityRole>() to Configuration of Startup.cs

ASP.NET Core Blazor authentication and authorization

ASP.NET Core supports the configuration and management of security in Blazor apps. Security scenarios differ between Blazor Server and Blazor WebAssembly apps. Because Blazor Server apps run on the server, authorization checks are able to determine: The UI options presented to a user (for example, which menu entries are available to a user). Access rules... » read more