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

xiaoxiao2021-02-28  122

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

转载请注明原文地址: https://www.6miu.com/read-23227.html

最新回复(0)