Simpaly created web app from Blazor Web App template and set authorizedview on home page to redirect to login. On login component replace original code with identity api endpoint
public async Task LoginUser() { try{ #region Original Code // // This doesn't count login failures towards account lockout // // To enable password failures to trigger account lockout, set lockoutOnFailure: true // var result = await SignInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: false); // if (result.Succeeded) // { // Logger.LogInformation("User logged in."); // RedirectManager.RedirectTo(ReturnUrl); // } // else if (result.RequiresTwoFactor) // { // RedirectManager.RedirectTo( // "Account/LoginWith2fa", // new() { ["returnUrl"] = ReturnUrl, ["rememberMe"] = Input.RememberMe }); // } // else if (result.IsLockedOut) // { // Logger.LogWarning("User account locked out."); // RedirectManager.RedirectTo("Account/Lockout"); // } // else // { // errorMessage = "Error: Invalid login attempt."; // } #endregion Original Code var response = await Http.PostAsJsonAsync("api/account/login", Input); if (response.IsSuccessStatusCode) { NavigationManager.NavigateTo("/"); } else { // Handle login failure var error = await response.Content.ReadAsStringAsync(); Console.WriteLine($"Login failed: {error}"); } } catch (Exception ex) { errorMessage = ex.Message; } } Home component
<AuthorizeView><Authorized> <h1>Hello, @context.User.Identity?.Name! ?? "world")!</h1></Authorized><NotAuthorized><p>You're not signed in.</p></NotAuthorized></AuthorizeView>Add Try catch block on login to check why successful response not redirecting to home page and exception catched as
Exception of type 'Microsoft.AspNetCore.Components.NavigationException' was thrown.at Microsoft.AspNetCore.Components.Server.Circuits.RemoteNavigationManager.NavigateToCore(String uri, NavigationOptions options)at Microsoft.AspNetCore.Components.NavigationManager.NavigateToCore(String uri, Boolean forceLoad)at Microsoft.AspNetCore.Components.NavigationManager.NavigateTo(String uri, Boolean forceLoad, Boolean replace)at BlazorWebAppAutoInteractive.Components.Account.Pages.Login.LoginUser()
Seeking a solutionTry few suggestion from developer community and gone through micorosoft docs.
Still no luck. Wondering anyone trapped in this!!! and overcome knowns issue