currently I'm trying to get the logout working in my Asp.Net Core 6 Blazor Server application.
Login is working fine. But logging out redirects to the login url with a redirect to the logout
I call the logout POST the following:(This is in a .razor file)
<form method="post" action="Identity/Account/LogOut" asp-area="Identity"><MudButton ButtonType="ButtonType.Submit" Variant="Variant.Outlined" Color="Color.Info"> Ausloggen</MudButton></form>The url that gets called is: https://localhost:7172/Account/Login?ReturnUrl=%2FIdentity%2FAccount%2FLogOut
I haven't changed the scaffolded Logout.cshtml file.
I'm registering my Identity like this:
builder.Services.AddDefaultIdentity<WaWiIdentityUser>(options =>{ options.SignIn.RequireConfirmedAccount = true; options.User.AllowedUserNameCharacters = "äabcdefghijklmnöopqrstüuvwxyzÄABCDEFGHIJKLMNÖOPQRSTÜUVWXYZ0123456789ß-._@+/ "; }) .AddRoles<WaWiIdentityRole>() .AddEntityFrameworkStores<WaWiIdentityContext>() .AddDefaultUI() .AddDefaultTokenProviders() .AddUserManager<UserManager<WaWiIdentityUser>>() .AddSignInManager<WaWiSignInManager>() .AddRoleManager<RoleManager<WaWiIdentityRole>>(); builder.Services.AddAuthentication("Identity.Application").AddCookie();The Authentication cookie does not get deleted and the default redirect is not getting called.
This is the default logout I'm using. I tried logging, but the method does not event get called as far as i can tell
@functions {public async Task<IActionResult> OnPost(){ if (SignInManager.IsSignedIn(User)) { await SignInManager.SignOutAsync(); } return Redirect("/");}}
Do I miss something here?
Thanks ahead for your help.