I am using a the basic login on a test ASP.Net MVC 5 site (for an internet site).
我正在测试ASP上使用基本的登录。Net MVC 5站点(用于internet站点)。
The login works fine but when I try to logout it doesn't happen. The logout link does call the following controller action:
登录操作正常,但当我尝试登出时,它不会发生。注销链接会调用以下控制器动作:
public ActionResult LogOff()
{
AuthenticationManager.SignOut();
return RedirectToAction("Index", "Home");
}
But the user stays logged in. How do I ensure that the user actually gets logged out?
但是用户仍然登录。如何确保用户实际注销?
3 个解决方案
#1
49
I had this problem before, change:
我以前遇到过这个问题,改变:
AuthenticationManager.SignOut();
To:
:
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
Assuming that you are using ApplicationCookie to store your login information.
假设您正在使用ApplicationCookie来存储登录信息。
#2
2
Better way :
更好的办法:
public ActionResult Logout()
{
SignInManager.AuthenticationManager.SignOut();
return RedirectToAction("Index", "support", new { area = "" });
}
or you can use injected SignInManager into your controller like this :
或者你可以像这样在控制器中使用注入的SignInManager:
public ActionResult Logout()
{
_signInManager.AuthenticationManager.SignOut();
return RedirectToAction("Index", "support", new { area = "" });
}
there is no deference.
没有尊重。
#3
-4
I had the same problem of not being able to logout. I would stay logged in and only redirect back to the home view. I was using Chrome and I tried it in firefox and ie and didn't have the problem. Then I cleared my cookies in chrome and it all worked fine. It could be a quick and easy first step if other encounter this problem.
我也有同样的问题无法登出。我将继续登录,只重定向回home视图。我用的是Chrome浏览器,我在火狐和ie上试过,没有问题。然后我用铬合金清理了我的饼干,一切都很好。如果其他人遇到这个问题,这可能是一个快速而简单的第一步。
#1
49
I had this problem before, change:
我以前遇到过这个问题,改变:
AuthenticationManager.SignOut();
To:
:
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
Assuming that you are using ApplicationCookie to store your login information.
假设您正在使用ApplicationCookie来存储登录信息。
#2
2
Better way :
更好的办法:
public ActionResult Logout()
{
SignInManager.AuthenticationManager.SignOut();
return RedirectToAction("Index", "support", new { area = "" });
}
or you can use injected SignInManager into your controller like this :
或者你可以像这样在控制器中使用注入的SignInManager:
public ActionResult Logout()
{
_signInManager.AuthenticationManager.SignOut();
return RedirectToAction("Index", "support", new { area = "" });
}
there is no deference.
没有尊重。
#3
-4
I had the same problem of not being able to logout. I would stay logged in and only redirect back to the home view. I was using Chrome and I tried it in firefox and ie and didn't have the problem. Then I cleared my cookies in chrome and it all worked fine. It could be a quick and easy first step if other encounter this problem.
我也有同样的问题无法登出。我将继续登录,只重定向回home视图。我用的是Chrome浏览器,我在火狐和ie上试过,没有问题。然后我用铬合金清理了我的饼干,一切都很好。如果其他人遇到这个问题,这可能是一个快速而简单的第一步。