开发者

Avoid form Re-Submit

开发者 https://www.devze.com 2023-01-17 11:45 出处:网络
I\'m developing ASP.NET applications and stuck with a \"problem\" relating to resubmit behaviour. I\'m controling the re-s开发者_StackOverflow中文版ubmit using a counter in form submit event which dis

I'm developing ASP.NET applications and stuck with a "problem" relating to resubmit behaviour. I'm controling the re-s开发者_StackOverflow中文版ubmit using a counter in form submit event which disables the submit if it's already been posted. My application is a 3 step workflow and when the 3rd step is shown the transaction was submited from step2 to step 3. What's my problem? Well... i want to avoid the user to resubmit the data by pressing the F5 or all other possibility. I don't want to disable the key because may be workarounds. I'm wondering if i can remove the post data in a HTTP module that runs after the render was completed and right before the response is sent to the user.


You can use Post/Redirect/Get "pattern", where when user post data, you redirect it (after processing submitted data) to another page that will response to get. Just like stackoverflow and another sites are doing.

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


Maybe I misunderstood your question/issue but it sounds like you may be making things harder than they have to be. If you are already keeping track of whether or not the form has been submitted before, why cant you just check that flag on the code behind before performing whatever logic you execute on the submit? If it has already been submitted before, just ignore the resubmit event and maybe set an error message.

0

精彩评论

暂无评论...
验证码 换一张
取 消