ASP.Net MVC 5 w/identity 2.2.0 Log off not working

后端 未结 3 890
不知归路
不知归路 2020-12-28 14:14

I am using a the basic login on a test ASP.Net MVC 5 site (for an internet site).

The login works fine but when I try to logout it doesn\'t happen. The logout link

相关标签:
3条回答
  • 2020-12-28 14:31

    I had this problem before, change:

    AuthenticationManager.SignOut();
    

    To:

    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
    

    Assuming that you are using ApplicationCookie to store your login information.

    0 讨论(0)
  • 2020-12-28 14:37

    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 :

    public ActionResult Logout()
    {
        _signInManager.AuthenticationManager.SignOut();
        return RedirectToAction("Index", "support", new { area = "" });
    }
    

    there is no deference.

    0 讨论(0)
  • 2020-12-28 14:51

    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.

    0 讨论(0)
提交回复
热议问题