我有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