I am doing web development.
I have a page to do with credit card, which when user click \"refresh\" or \"Back\", the transaction will be performed one more time, wh
The standard way is to do it in 3 steps.
I didn't see this here so here it is.
If the session variable is not found, the form will not be processed. Since the variable is removed as soon as its found, the form can only be run by pressing the submit button. Refresh and back will not submit the form. This will work without the use of a redirect.
Place this code on the form page
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.Now-new TimeSpan(1,0,0));
Response.Cache.SetLastModified(DateTime.Now);
Response.Cache.SetAllowResponseInBrowserHistory(false);
The best way is to have enough session handling logic that you can recognise the 2nd (and onwards) attempt as "this is just a re-submission" and ignore it.
generate a random string and store it in session,
then output it to your form as a hidden value,
check the submitted and store variable, if matches process your request,
go to 1.
vartec:s solution solves the reload-problem, not the back-problem, so here are a solution to that:
Then if the user is pressing back button, the processing page will not do the process again, only redirect to process page.