1
我已经使用Session.Abandon();
Session.Clear();
在注销按钮并重定向到登录页面。 但是 当我点击浏览器的后退按钮时,我仍然会回到页面。当我点击浏览器的后退按钮时,我仍然回到
我已经使用Session.Abandon();
Session.Clear();
在注销按钮并重定向到登录页面。 但是 当我点击浏览器的后退按钮时,我仍然会回到页面。当我点击浏览器的后退按钮时,我仍然回到
因为它是从缓存中获取页面,所以您可能希望为这些相应的页面禁用缓存。
有些人要求禁用后退按钮,因此无法禁用后退按钮。替代方案是:
对于第二种情况,请查看以下代码并将其放入您的登录页面。
<script type = "text/javascript" >
function changeHashOnLoad() {
window.location.href += "#";
setTimeout("changeHashAgain()", "50");
}
function changeHashAgain() {
window.location.href += "1";
}
var storedHash = window.location.hash;
window.setInterval(function() {
if (window.location.hash != storedHash) {
window.location.hash = storedHash;
}
}, 50);
</script>
,并调用它象下面这样:
<body onload="changeHashOnLoad(); ">
//---Rest of your code
它会在所有的浏览器。
来源:SO(没有链接到原来的线程)
您可以使用像使用如下
FormsAuthentication.SignOut();
Session.Abandon();
// clear authentication cookie
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);
// clear session cookie (not necessary for your current problem but i would recommend you do it anyway)
HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);
FormsAuthentication.RedirectToLoginPage();
能否请你添加一些标签,告诉我们一些关于你的环境? – Trinimon
是的,我已经添加标签C# –