Disabling browser’s back functionality after logout
I want to disable browser's back button after log out.
I have already set session["session-id"] to null on log out event.
But when I am pressing Back button of browser,it will redirect me to that secure page from which I've already log out.
Solution
-----------------------------------------------------------------------------------------------------------------------
When we request any page from server, browser maintains its cache in local system. When user press back button the cached page opened in front of user.
Its mean we have to disable the cache functionality for our session pages. So for this you have to insert this code into “Page_Load” event of the session page or to master page that is used for secure pages.
Its mean we have to disable the cache functionality for our session pages. So for this you have to insert this code into “Page_Load” event of the session page or to master page that is used for secure pages.
Response.Buffer= true;
Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
Response.Expires =-1500;
Response.CacheControl = "no-cache";
if(Session["SessionId"] == null)
{
Response.Redirect ("WhereYouWantToGo.aspx");
}
}
This code just disable the cache for current page and save this page in buffer.
And buffer is maintained in memory so when user log
out the buffer will
destroy and no backup copy of that page available to view.
So its mean we successfully disable the back button.
And buffer is maintained in memory so when user log
out the buffer will
destroy and no backup copy of that page available to view.
So its mean we successfully disable the back button.
No comments:
Post a Comment