使用Asp.net开发,使用Forms验证,在退出按钮里写 FormsAuthentication.SignOut() 并清除Session和Cookie,发现退出后,使用Request.IsAuthenticated获取到的值依然是True。
解决办法:
FormsAuthentication.SignOut() 必须写在逻辑最后,在执行FormsAuthentication.SignOut()方法后,不能再进行清除Cookie的操作。或者写入session清除更明了有效。
public ActionResultLogout(){FormsAuthentication
.SignOut();Session
.RemoveAll();}
参考文章http://demo.tc/Post/700