浏览器的后退按钮在asp.net中单击后网页不会过期 [英] Webpage not expiring after browser's backbutton click in asp.net

查看:72
本文介绍了浏览器的后退按钮在asp.net中单击后网页不会过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有登录页面,登录后我重定向到用户可以退出的个人资料页面,退出后我再次重定向到同一登录页面,我已经使用以下方法来清除浏览器会话(我使用的是IE 8和FireFox)。但他们没有工作。当我点击登录页面中的后退按钮时,显示上一页而不是网页过期消息。



 HttpContext.Current.Response.Cache .SetAllowResponseInBrowserHistory( false ); 
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.Now.AddSeconds( 60 ));
Response.Cache.SetValidUntilExpires( true );





这里我们在登录后对登录页面和个人资料页面使用相同的母版页。我在主页和登录页面都添加了上述方法。但他们没有工作。建议我一些解决方案,当用户在注销后点击浏览器中的后退按钮,然后网页必须过期。

解决方案

试试这个脚本。



 <   script  >  
function preventBack(){window.history.forward();}
setTimeout(preventBack(),0);
window.onunload = function(){null};
< / script >


Hi All,

I have a login page, after login i am redirecting to profile page where users can logout, after logout i am again redirecting to same login page, and i have used the following methods to clear the browser session(I am using IE 8 and FireFox). but they are not working. When I click back button in Login page, previous page is displaying instead of webpage expire message.

HttpContext.Current.Response.Cache.SetAllowResponseInBrowserHistory(false);
    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    HttpContext.Current.Response.Cache.SetNoStore();
    Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
    Response.Cache.SetValidUntilExpires(true);



Here we are using same master page for both login page and profile page after login. And I have added the above methods In both master page and in login page. But they are not working. Suggest me some solution, when user clicks back button in browser after logout, then webpage must expired.

解决方案

try this script.

<script>
  function preventBack(){window.history.forward();}
  setTimeout("preventBack()", 0);
  window.onunload=function(){null};
</script>


这篇关于浏览器的后退按钮在asp.net中单击后网页不会过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆