Wednesday 28 November 2012

Deny or avoid user on browser back button after Logout

Problem:

A very common problem that we face in web application is that when user logged out, and again click the browser back button, it shows the last accessed page by the user when user was logged in, even we have included any check whether the user is signed inn or not, it is because browser shows the cached webpage.

Solution:

After some net surfing , I was able to solve my issue by including these code of snippets in my code :

  Response.Cache.SetCacheability(HttpCacheability.NoCache);
  Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
  Response.Cache.SetNoStore();
  Response.AppendHeader("Pragma", "no-cache");

Hope this helps.
 

No comments:

Post a Comment

Test Email without sending Email to User - C# / C-Sharp - DotNet

Sometimes we may want to test email functionality without sending email to actual user. Email will be saved locally so that we can verify ...