views:

67

answers:

2

Hi,

I'm wondering if there is any way to detect when a page is being reloaded after hitting the back button of a navigator, in ASP .NET?

Thanks

+5  A: 

Unfortunatly as far as I know there is no fail safe way to do this, as it depends primarially on the browser. Some browsers will physically reload the content when you press back, others will cache it and just load a cache. Others will do a mix of both.

Tom Gullen
Interesting to know that browsers don't work the same for the back button. Apparently:Some browsers will physically reload the content when you press back => Internet Explorer.thers will cache it and just load a cache => Firefox.
Amokrane
Comes down to a lot of user settings as well, and how browsers treat certain meta tags.
Tom Gullen
Also comes down to how much storage is allowed for the history stack. FF gives a cached version (not the same as web-cache, but a copy of the state when you left the page), however, do enough work in FF (including in other tabs and windows) and that state gets flushed, and it has to do a reload.
Jon Hanna
+2  A: 

Client-side script can have some success in this, but the differences between browsers is considerable.

Conceptually, it makes little sense to do, as you would presumably then do something on the basis of this knowledge, which would change "history". Don't change history! :)

The most common class of problem I've found to make one want to do this is re-submission of a form, following a back. I would normally solve this by including a nonce in the form, and rejecting repeated nonces. UUIDs are handy in these cases.

Other cases have other solutions.

Jon Hanna