解决方案1:禁用缓存,前一次使用的方法,在电脑上各浏览器都没问题,但在ipad、安卓手机上仍有问题
asp.net方法
因为客户端缓存了页面
1 Response.Buffer = true; 2 Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1); 3 Response.Expires = 0; 4 Response.CacheControl = "no-cache";
在你的page_load里面加上上面的代码,强制不缓存页面
你退出的话,要把当前会话ID(sessionid)清掉
强制登录,需要在页面上判断session是否存在,不存在就跳回到登录页面,存在就继续访问
HTML方法
<HEAD> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> </HEAD>
解决方案2:禁用浏览器后退键 javascript: window.history.forward(1); 结果和方案一一样的结果,pad上没效果
解决方案3:Response.Write("<script>window.location.replace('login.aspx')</script>");仍旧可以后退,感觉还不如1、2,但是在前台加个onclick事件,不涉及表单提交,竟然可以,由此就到方案4
解决方案4:用ajax,在ajax页面里将session清空,然后在现在的页面加js
function logout(isLogout) {
if (isLogout != "") {
$.ajax({
url: "ajax/logout.aspx",
data: "code=" + encodeURI(isLogout), cache: false,
datatype: "html",
success: function (context) {
LogoutReturn(context);
}
});
}
else {
return "Error";
}
}
function LogoutReturn(context) {
if (context == "success") {
location.replace('login.aspx');
}
}
好了,算是解决了问题。
参考:http://bbs.csdn.net/u/20110519/15/bda40bee-100c-4054-a3d8-eb8b2ff2ee68.html