session problem when i click logout it redirect to logout.aspx
but when i click backward button it remain goes to to logout page
how to solve this
this is my code for logut
protected void Page_Load(object sender, EventArgs e)
{
Session.Abandon();
Session.Clear();
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetAllowResponseInBrowserHistory(false);
FormsAuthentication.SignOut();
Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 5) - 120));
Response.Redirect("login.aspx");
}
Sunny SharmaPosted Jan 24, 2014, 7:03 AM
If it's a page, are you checking if the user is authenticated in Page_Load of logout.aspx?
Biswa Pujarini MohapatraPosted Jan 24, 2014, 6:32 AM
http://smewara.wordpress.com/2013/01/31/browser-back-button-issue-after-logout/
Shridhar JoshiPosted Jan 24, 2014, 6:24 AM
http://www.codeproject.com/Tips/632336/Disabling-browsers-back-button
muthukumarPosted Jan 24, 2014, 6:05 AM
Shridhar JoshiPosted Jan 24, 2014, 5:47 AM
Try to disable backbutton of browse for login page using java script like this
<SCRIPTtype="text/javascript">window.history.forward();function noBack() { window.history.forward(); }SCRIPT>HEAD><BODYonload="noBack();"onpageshow="if (event.persisted) noBack();"onunload="">
All the best
muthukumarPosted Jan 24, 2014, 5:33 AM
but my problem is when i click backward button in browser it goes to logout.aspx
(i.e) <---- this in google chrome it once again goto logout page
after logout when click backward it should not got to logout.aspx from login.aspx
Sunny SharmaPosted Jan 24, 2014, 5:14 AM
try this code inside your Page_Load() block of logout page:
***********************************************
Session.Abandon();
Session.Clear();
FormsAuthentication.SignOut();
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-2000;
Response.CacheControl = "no-cache";
//Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 5) - 120));
//why to wait 5 minutes after logout, just redirect to login page.
Response.Redirect("login.aspx");
***********************************************
Hope it helps!