How can i stop the back button after user has logout ? (LOGOUT button is in master page) Using webforms
I have few pages, the last page is the final page and after log out when i click back button its showing the previous page.How do i avoid this.Pls help me with the code
Code needs to trigger only after LOGOUT .The user must be able to go back n see previous page if he has to make any changes while he's loged in.
You should set the correct HTML headers. According to this these are the ones that work on all browsers:
Cache-Control: no-cache, no-store, must-revalidate
Pragma: no-cache
Expires: 0
You can set them like this:
HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate");
HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
HttpContext.Current.Response.AddHeader("Expires", "0");
<script>
function preventBack(){window.history.forward();}
setTimeout("preventBack()", 0);
window.onunload=function(){null};
</script>
it may work for you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With