Handle back button of the browser
Posted by Virendra Dugar on February 11, 2009
The “Back” browser button cannot be actually disabled by a web application as the browser security will not allow this.
This method will always redirect to the user on the current page itself.
For example, user is on page 1 and user goes to Page 2. Now from page 2 if user press back button of the browser then user will be redirect to the page 2 itself.
window.history contains the collection of the page visited by the user for particular browser session. window.history.go(+1) and window.history.forward(); are same.
But if we want to display web page expired warning on the click of back button, then we must allow the browser to cache the page. This can be achieved by ASP.NET
/*To not to store the page in cache.*/
But one problem with this approach is that this will only work when there are some dynamic content in the page. i.e. change any combo or dropdown box value and then try to press back button.
If you can find out better solution then this please let me also know.