How to logout user in OWIN ASP.NET MVC5

前端 未结 6 2038
不思量自难忘°
不思量自难忘° 2020-12-31 11:30

I have got a standard AccountController class of ASP.NET MVC5 project. When I try to log out user I am facing an error coz HttpContext

6条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-31 12:21

    I tried all this out:

    System.Web.HttpContext.Current.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
    FormsAuthentication.SignOut();
    AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
    
    Request.GetOwinContext().Authentication.SignOut();
    
    Request.GetOwinContext().Authentication.SignOut(Microsoft.AspNet.Identity.DefaultAuthenticationTypes.ApplicationCookie);
    

    but finally this solved my problem:

    HttpContext.User = new GenericPrincipal(new GenericIdentity(string.Empty),null);
    

    Check

提交回复
热议问题