Avoid resubmitting the form

I am developing ASP.NET applications and am sticking to the β€œproblem” associated with re-posting. I control the resubmission using a counter in the submit form, which disables sending if it has already been submitted. My application is a three-step workflow, and when the third step is shown, the transaction was sent from step 2 to step 3. What is my problem? Well ... I want the user to not be able to resend the data by pressing F5 or any other option. I do not want to disable the key because this can be a workaround. I am wondering if I can delete the message data in the HTTP module, which starts after the rendering is complete and immediately before sending the response to the user.

+6
source share
2 answers

You can use the "Post / Redirect / Get" template, where when sending user data you redirect it (after processing the submitted data) to another page to which you will receive a response. Just like stackoverflow and other sites.

Here is the Wikipedia page that explains Post / Redirect / Get Pattern .

+5
source share

I may have misunderstood your question / question, but it looks like you can do something harder than it should be. If you are already tracking whether a form has been submitted before, why can't you just check this flag on the code behind before executing any logic that you execute in submit? If it has already been submitted, just ignore the resubmit event and maybe set an error message.

+2
source share

All Articles