Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,
I have a user login page('Default page') which validates n redirects to 'Orders page'.
but once user logout and click on browser back button its taking me back to the orders page.how do i avoid this?
i used script in default page


XML
<script type="text/javascript" language="javascript">
     window.history.forward(1);
     document.attachEvent("onkeydown", my_onkeydown_handler);
     function my_onkeydown_handler() {
         switch (event.keyCode) {
             case 116: // F5;
                 event.returnValue = false;
                 event.keyCode = 0;
                 window.status = "We have disabled F5";
                 break;
         }
     }
</script>

AND this piece of code in Masterpage code behind

C#
Session.Clear();
        Session.Abandon();


Please help!
Posted

You should not write "disabled F5". The particular key depends on the browser.

This is a very popular question, so you could find the solution in many places. The idea is to disable browser caching. On CodeProject along, this question was answered many times: http://www.codeproject.com/search.aspx?q=ASP.NET+disable+back+button&doctypeid=5[^].

—SA
 
Share this answer
 
you may paste this code in your page meta tag , that will avoid browser to cache history

XML
<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">
 
Share this answer
 
Comments
Challa92 13-Feb-14 5:39am    
i tried those..The problem is either after logout that page is going back to the previous page or from login page the forward browser is working!
 
Share this answer
 
v2
Try these

[^]

[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900