Hey there,
I'm facing a issue, that the user cannot log out, because the logout does get redirected to a path that's non existend.
I've tried scaffolding the identity framework again, but this didn't help either.
If I use the Account/LogOut
or /Account/LogOut
url the user gets redirected to: https://localhost:7172/Account/Login?ReturnUrl=%2FIdentity%2FAccount%2FLogOut
.
I also tried Logout
instead of LogOut
. Didn't help either.
The route doesn't exist because I get the router defined message for there is nothing: Sorry, there's nothing at this address.
I'm using the logout call like this: (I'm using Mudblazor, thus the MudButton component usage. But this doesn't work with a default html button either)
<form method="post" action="Identity/Account/LogOut">
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Outlined" Color="Color.Info">
Ausloggen
</MudButton>
</form>
I'm using a Cookie authentication, that has been configured the following way:
builder.Services.AddAuthentication("Identity.Application").AddCookie();
builder.Services.ConfigureApplicationCookie(options => { });
And haven't changed the logout scaffolded .cshtml
@page
@using Microsoft.AspNetCore.Identity
@using Microsoft.AspNetCore.Authentication
@attribute [IgnoreAntiforgeryToken]
@inject SignInManager<WaWiIdentityUser> SignInManager
@functions {
public async Task<IActionResult> OnPost()
{
if (SignInManager.IsSignedIn(User))
{
await SignInManager.SignOutAsync();
}
return Redirect("/");
}
}
Edit:
I checked the server answer, and as a result the client gets the status code 302 and the mentioned url: https://localhost:7172/Account/Login?ReturnUrl=%2FIdentity%2FAccount%2FLogout
I also tried setting the LogoutPath in the authentication and the applicationcookie but this doesn't help either.
builder.Services.AddAuthentication("Identity.Application")
.AddCookie(options => options.LogoutPath = "/Identity/Account/Logout");
builder.Services.ConfigureApplicationCookie(options =>
{
options.LogoutPath = "/Identity/Account/Logout";
});
Thanks ahead for any help!