Detect browser refresh

后端 未结 2 1088
感情败类
感情败类 2021-01-13 04:13

How can I find out if the user pressed F5 to refresh my page (Something like how SO implemented. If you refresh your page, the question counter is not increased). I have tes

2条回答
  •  逝去的感伤
    2021-01-13 04:46

    The only sure solution is to make a redirect to the same page , and here is a similar question: Post-Redirect-Get with ASP.NET

    But there are also some other tricks, by adding some ticket on the page and see if this is the same or have change, see the full example and code at:

    http://www.codeproject.com/Articles/68371/Detecting-Refresh-or-Postback-in-ASP-NET

    and one more:

    http://dotnetslackers.com/community/blogs/simoneb/archive/2007/01/06/Using-an-HttpModule-to-detect-page-refresh.aspx

提交回复
热议问题