Friday, May 15, 2009

Remove the Cache if back button pressed in browser

The session of the login person should expire if the user presses the back button of the browser. the login page should be displayed or the session expired page should be display. for that we have to add this function in the page load of each page so that. the cache will be cleared and the page will load again so that the session will expire.
the function of that cache clear is as follows
---------------------------------------------------------------------------------
public static void DisablePageCaching()
{
//Used for disabling page caching
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();
}
---------------------------------------------------------------------------
Page load method:

DisablePageCaching();
if (Session["abandon"] != null && Session["abandon"].ToString() == "abandon")
Session.Abandon();
-------------------------------------------------------------------------------
Thus we cannot use back button in the browser, session will expire
by
கண்ணன்.மா.கா

No comments:

Post a Comment

HTML/JAVASCRIPT BLOG

You can find the help for html and javascript codes

Any Doubts Contact my Mail-ID:
kannan.mkv@gmail.com