Click to See Complete Forum and Search --> : back button in the browser
rahulvasanth
June 7th, 2006, 01:11 AM
In a web browser, If I click the browser's back button at any time, it does not invoke the page_load event for that particular page. Is there any way I can trigger the page_load event of the page when the back button of the browser is clicked in ASP.NET?
Thanking in advance
Shuja Ali
June 7th, 2006, 05:32 AM
Browsers usually cache the pages and when you press the back button on the browser they load the page back from the cache. In order to achieve what you are looking for you need to disable that caching. Add this code to your Page_load event Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.AppendHeader("Pragma", "no-cache")
Response.AppendHeader("Cache-Control", "no-store")
Response.AppendHeader("Expires", "-1") This is should re-load the page everytime you click the back button.
Roles
June 7th, 2006, 11:19 AM
Thanks a lot for this code. Was looking for something like that for a period.
Roles
jasonli
June 9th, 2006, 09:10 AM
I think it is not very good idea for aspx web page. Assuming that I redirect to another web page after original web page is ever postbacked. So when I click back button, web page shows error:
Warning: Page has Expired
The page you requested was created using information you submitted in a form. This page is no longer available. As a security precaution, Internet Explorer does not automatically resubmit your information for you.
To resubmit your information and view this Web page, click the Refresh button.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.