Best Industrial Training in C,C++,PHP,Dot Net,Java in Jalandhar

Sunday 22 December 2013

Prevent back button after logout in asp.net


When you log in into a site then the browser saves the pages (visited) in cache by default. After logout, you found that you can still click the go back button of the browser and the page content will show again, which is not desired. How do I prevent that?

We can ignore this problem by clearing the cache of page by writing code in the Master Page:

  protected void Page_Init(object sender, EventArgs e)
    {
        Response.Cache.SetExpires(DateTime.Now.AddMinutes(-1));
        Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.Cache.SetNoStore();
    }

 Conclusion: I have shown  in this article, how to prevent back button after logout in asp.net. I hope this post was useful.

No comments:

Post a Comment