The problem is that your RedirectToAction
overwrites the redirect to the Identity Server endsession URL that SignOutAsync
issues.
As for SignOutAsync
, what is obsolete is the Authentication
portion — as of ASP.NET Core 2.0 it’s an extension directly off HttpContext
itself.
(The same explanation for the same signout problem is given here by Microsoft’s HaoK.)
Edit: The solution is to send a redirect URL in an AuthenticationProperties
object with the final SignOutAsync
:
// in some controller/handler, notice the "bare" Task return value
public async Task LogoutAction()
{
// SomeOtherPage is where we redirect to after signout
await MyCustomSignOut("/SomeOtherPage");
}
// probably in some utility service
public async Task MyCustomSignOut(string redirectUri)
{
// inject the HttpContextAccessor to get "context"
await context.SignOutAsync("Cookies");
var prop = new AuthenticationProperties()
{
RedirectUri = redirectUri
};
// after signout this will redirect to your provided target
await context.SignOutAsync("oidc", prop);
}