2014-08-28 213 views
0

我已经经历了一些链接并花费了几个小时,但在退出后单击返回按钮后,我的页面仍然加载。这里是我注销的页面代码,我试过了。退出按钮退出后的问题

protected void Page_Load(object sender, EventArgs e) 
    { 
    if(Session[Constants.KeyValues.UserProfileSession]== null) 
    { 
      Response.Redirect("www.google.com", true); 
    }   

     ////Clear cookie and redirect user to login page (Landing page before login). 
     Response.AddHeader("pragma", "no-cache"); 
     Response.AddHeader("cache-control", "private"); 
     Response.CacheControl = "no-cache"; 
     Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1)); 
     Response.Cache.SetCacheability(HttpCacheability.NoCache); 
     Response.Cache.SetNoStore(); 
     FormsAuthentication.SignOut(); 
     Response.Cookies.Clear(); 

     HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1)); 

     HttpContext.Current.Response.Cache.SetValidUntilExpires(false); 
     HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches); 
     HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); 
     HttpContext.Current.Response.Cache.SetNoStore(); 


     Session.Clear(); 
     Session.Abandon(); 
     Session[Constants.KeyValues.UserProfileSession] = null;    
     Response.Write("<script type=\"text/javascript\">window.location.replace('www.google.com');</script>"); 
     //Response.Redirect("www.google.com", true); 
    } 

这里是我的html页面

<!doctype html> 
<html lang="ko"> 
<head> 
    <title></title> 
    <meta http-equiv="Cache-Control" content="no-cache" /> 
    <meta http-equiv="Pragma" content="no-cache" /> 
    <meta http-equiv="Expires" content="0" /> 
    <script type="text/javascript"> 
     function ClearHistory() { 
      var backlen = history.length; 
      history.go(-backlen); 
      window.location.href = www.google.com 
     } 
    </script> 
</head> 
<body onload="ClearHistory();"> 
</body> 
</html> 

这里是页面加载的代码,其中登录后成员去

protected void Page_Load(object sender, EventArgs e) 
    { 
    if(Session[Constants.KeyValues.UserProfileSession]== null) 
    { 
      Response.Redirect(SPContext.Current.Site.Url + "/_layouts/ABC/ShoppingLandingBeforeLogin.aspx", true); 
    } } 

以下是我已经尝试了联系。

How to clear browser cache when user log off in asp.net using c#?

How to prevent browser and proxy caching of web pages

Browser back button issue after logout

Clear History using javascript

back-button-of-browser-issue-in-asp-net-logout

+0

是什么问题? – 2014-08-28 09:10:27

+0

这不是您需要更改的注销页面的可缓存性 - 这是您要返回的页面的可缓存性。该页面上的缓存标题是什么? – 2014-08-28 09:12:25

+0

我不希望用户在注销后重定向到成员页面。我不能禁用后退按钮,但可以清除浏览器的捕获。或者任何其他方法来实现我的目标。 – 2014-08-28 09:13:03

回答

0

尝试使用这个,它工作在所有浏览器。

Response.AppendHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. 
    Response.AppendHeader("Pragma", "no-cache"); // HTTP 1.0. 
    Response.AppendHeader("Expires", "0"); // Proxies. 
+0

团队:完全没有进展。你能建议其他能够帮助我的东西吗? – 2014-08-28 13:00:12

+0

我已阅读帖子[back-button-issue-after-logout](http://geekswithblogs.net/Frez/archive/2010/05/18/back-button-issue-after-logout-in-asp.net的.aspx)。我已经在我的页面中实现了它。它运作良好。唯一要记住的要点是 - >不要通过页面加载重定向。谢谢。 – 2014-09-16 08:12:35