2014-08-28 6 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

В чем проблема? –

+0

Это не кешируемость страницы выхода, которую нужно изменить - это кешируемость страницы, к которой вы возвращаетесь. Каковы заголовки кеширования на этой странице? –

+0

Я не хочу, чтобы пользователь был перенаправлен на страницу участника после выхода из системы. Я не могу отключить кнопку «Назад», но может очистить улов браузера. Или любой другой метод для достижения моей цели. –

ответ

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

команда: Никакой прогресс вообще. Можете ли вы предложить что-нибудь еще, что может помочь мне в этом? –

+0

Я прочитал сообщение [back-button-issue-after-logout] (http://geekswithblogs.net/Frez/archive/2010/05/18/back-button-issue-after-logout-in-asp.net .aspx). Я реализую его на своей странице. Это работает хорошо. Единственное, что нужно запомнить: -> не перенаправлять через загрузку страницы. Благодарю. –