我有Asp.net Core Identity版本2.0設置和運行。我發現_signinManager.SignoutAsync在用戶登錄Google後沒有註銷。當我回到我的登錄方法時,它只是顯示用戶登錄時其聲明對象仍然完好無損。ASP.NET Core Identity 2.0 SignoutAsync
的代碼如下
[AllowAnonymous]
public ActionResult TestGoogle()
{
var redirectUrl = Url.Action(nameof(ExternalCallback), "Account", new { ReturnUrl = "" });
var properties = _signInManager.ConfigureExternalAuthenticationProperties("Google", redirectUrl);
return Challenge(properties, "Google");
}
public async Task<IActionResult> LogOff()
{
await _signInManager.SignOutAsync();
return RedirectToAction(nameof(HomeController.Index), "Home");
}
嗨,也許是餅乾。嘗試在您註冊: await HttpContext.Authentication.SignOutAsync(「yourcookie」); –
看着這個答案,但VS說,該方法已過時,將在未來版本中刪除。所以想避免。 – AliK