Redirecting to an error page when the user clicks the Refresh Browser button
If you include each link, you provide a unique identifier (such as GUID) in the URL as a parameter, then you can track all requests that you processed. (You can clean up "old" requests if you don't mind the mechanism not working if someone leaves the browser open for a few days and then removes the update.) The first time you see the GUID, write it down to the table. If you see it again, please go to the error page.
This is pretty ugly and users can just change the URL to change the GUID slightly. (You can correct this last flaw by writing down the GUID when you create it, and update the table to indicate when it was used.)
In general, users expect to be able to refresh the page, especially for GET requests (although most users don't know what that means). Why would you want to do that?
source to share
Ok, you can use a very famous tectonics called "Sync Token" or something like this = D, mostly used for submitting forms.
It will work like this:
-
Create a function to provide a pseudo random string character.
-
For each request to your page, check if there is a variable in the session, for example: Session ["synctoken"], if there is one. If not, this is the first time, generate a token and save it there.
-
Each link request, for example: "mypage.aspx" places a call called synctoken with a different token than the one you saved in the session, it looks like "mypage.aspx? Synctoken = 2iO02-3S23d".
-
Then, back to (2), in the request, if the token is present in the check session, whether GET is present (Request.QueryString ["synctoken"]! = Null). If not, please submit a bug report. If yes, check if the tokens (session and GET) are different. If they are different, that's okay, store the GET in your session (Session ["synctoken"] = Request.QueryString ["synctoken"]) and go to step (2). If not, then the user has refreshed the page, an error will occur.
It looks like this:
if (Session["synctoken"] != null) {
if (Request.QueryString["synctoken"] != null) {
if (Request.QueryString["synctoken"].ToString().Equals(Session["synctoken"].ToString())) {
// Refresh! Goto Error!
MyUtil.GotoError();
}
else {
// It is ok, store the token and go on!
Session["synctoken"] = Request.QueryString["synctoken"];
}
}
else {
MyUtil.GotoErrorPage();
}
}
else {
Session["synctoken"] = MyUtil.GenerateToken();
}
Sorry if I can't be clearer .. good luck!
source to share