开发者

How to catch an event when hitting the back button?

I'm wondering if there is any way to detect when a page is being reloaded after hitting the back button of a navig开发者_Python百科ator, in ASP .NET?

Thanks


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜