USING SYSTEM.Threading.Tasks; USING Microsoft.AspNetCore.Components; USING Microsoft.JSInterop; USING ApprovementWorkflowSample.Applications; USING Microsoft.AspNetCore.Identity; USING SYSTEM.Security.Claims; USING Microsoft.AspNetCore.Components.Authorization; USING Microsoft.AspNetCore.Authentication.Cookies; namespace ApprovementWorkflowSample.Views { public partial class SignIn { [Inject] public IJSRuntime? JSRuntime { GET; init; } [Inject] public NavigationManager? Navigation { GET; init; } [Inject] public IApplicationUserService? ApplicationUsers{GET; init; } [Inject] public SignInManager<ApplicationUser>? SignInManager { GET; init; } [Inject] public IHostEnvironmentAuthenticationStateProvider? HostAuthentication { GET; init; } [Inject] public AuthenticationStateProvider? AuthenticationStateProvider{GET; init; } ... public async Task StartSigningIn() { ... ApplicationUser? user = await ApplicationUsers!.GetUserByEmailAsync(Email); IF(user == null) { await HandleSigningInFailedAsync("Email or Password are not match"); RETURN; } SignInResult loginResult = await SignInManager!.CheckPasswordSignInAsync(user, Password, false); IF(loginResult.Succeeded == false) { await HandleSigningInFailedAsync("Email or Password are not match"); RETURN; } IF(loginResult.Succeeded) { ClaimsPrincipal principal = await SignInManager.CreateUserPrincipalAsync(user); SignInManager.Context.User = principal; HostAuthentication!.SetAuthenticationState( Task.FromResult(new AuthenticationState(principal))); // IF you don't need doing anything without moving to next page, you can remove this. AuthenticationState authState = await AuthenticationStateProvider!.GetAuthenticationStateAsync(); Navigation!.NavigateTo("/Pages/Edit"); } }