我有一个ASP .NET MVC核心应用程序,我正在实现一个非常简单的登录页面,我使用IdentityUser让用户使用用户名,电子邮件和密码登录 . 我也在使用Facebook等外部身份验证提供商 . 正常登录/注销正常工作 . 说到Facebook,登录工作正常:
public IActionResult FacebookLogin()
{
AuthenticationProperties authProps = new AuthenticationProperties
{
RedirectUri = Url.Action("Index", "Home")
};
return Challenge(authProps, "Facebook");
}
但是当我使用Facebook登录时,我有登出的问题 . 这是我的注销代码:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Logout()
{
await _signinManager.SignOutAsync();
return RedirectToAction("Index", "Home");
}
无论我做什么,当我使用Facebook登录时都无法注销任何帮助 . 值得注意的是,我的部分观点如下:
每当我使用facebook登录时,IsAuthenticated标志设置为true,但是当我退出时,它永远不会设置为false
1 回答
感谢@ R.Richards分享旧帖子 . 你可以看到here
我选择在我的注销操作方法中使用以下代码:
在我的 Startup.cs 和 Configure 方法中:
在我的 AccountController 中的 Logout 动作方法中: