FormsAuthentication.SignOut() 后,并未真正退出的原因

来源:互联网 发布:php正则表达式 编辑:程序博客网 时间:2024/06/05 16:32

使用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

阅读全文
0 0
原创粉丝点击