使用Asp.net开发,使用Forms验证,在退出按钮里写 FormsAuthentication.SignOut() 并清除Session和Cookie,发现退出后,使用Request.IsAuthenticated获取到的值依然是True。

解决办法:

FormsAuthentication.SignOut() 必须写在逻辑最后,在执行FormsAuthentication.SignOut()方法后,不能再进行清除Cookie的操作。

或者写入session清除更明了有效。

  1. public ActionResultLogout()
  2. {
  3. FormsAuthentication.SignOut();
  4. Session.RemoveAll();
  5. }

参考文章http://demo.tc/Post/700

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-08-08
  • 2022-03-10
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-30
  • 2022-01-18
  • 2021-04-02
  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
相关资源
相似解决方案