A common problem that Web Application Developers encounter is how to stop the user from refreshing the page. This is a problem if the previous request to the server was a PostBack, which, for example, inserted the WebForm’s data into a database. This will result into the addition of duplicate rows in the database. But we have constraint that we can’t stop user by refreshing the page, So What to do? Although we can’t stop user from refreshing the page but we can however determine if this event has occurred and then take appropriate action.
This article is result of inspiration from article “Build Your ASP.NET Pages on a Richer Bedrock” in which Dino Esposito outlined a mechanism to detect a page refreshes. But the problem with this method is that it is cumbersome and more complicated than necessary, although the fundamental idea is sound and forms the basis of this solution. Dino’s mechanism uses a counter stored on the page and a session variable to store the previous request’s counter on the server, if the two match then we have a page refresh.
[More at Code Project]