asp.net中的后退按钮显示IE11中的历史记录

时间:2016-01-07 07:10:13

标签: javascript c# asp.net vb.net

我的下面的代码在Firefox和chrome中工作正常。但是当我在IE 11中打开网站并登录然后我按下注销按钮然后我按下后退按钮然后我以前的数据(历史页面)是出现。如何在IE11中解决这个问题。

我的注销按钮代码如下

// Code disables caching by browser. Hence the back browser button
// grayed out and could not causes the Page_Load event to fire 
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();
Response.Redirect("~/main.aspx);

2 个答案:

答案 0 :(得分:0)

在您的主页上使用此javascript来禁用浏览器的历史记录

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

答案 1 :(得分:0)

只需在Page_Load()中添加行代码:

Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);