2

How to restrict previous , operation after re submission. example if I click on one button if I resubmit (f5) that page will refresh , whatever we previously clicked button will execute once again. so I don't want to execute once again. So can you help me to solve this problem ?

user3239173
  • 89
  • 1
  • 3
  • 12
  • Is this part two of another question? I'm missing some imformations. Where is the code that does not work, is this winforms or webforms? If this is ASP.NET there are plenty of [duplicates](http://stackoverflow.com/questions/12353461/how-to-prevent-data-from-sending-if-user-press-f5-or-refresh-in-asp-net)(or http://stackoverflow.com/questions/3759572/avoid-form-re-submit or http://stackoverflow.com/questions/2526568/asp-net-prevent-form-submission-twice). – Tim Schmelter Jan 29 '14 at 12:45

2 Answers2

3

You should read about PRG pattern:

Post/Redirect/Get (PRG) is a web development design pattern that prevents some duplicate form submissions, creating a more intuitive interface for user agents (users). PRG implements bookmarks and the refresh button in a predictable way that does not create duplicate form submissions.

More about this here.

Short explanation of the way it works:

When a web form is submitted to a server through an HTTP POST request, a web user that attempts to refresh the server response in certain user agents can cause the contents of the original HTTP POST request to be resubmitted, possibly causing undesired results, such as a duplicate web purchase. To avoid this problem, many web developers use the PRG pattern1 — instead of returning a web page directly, the POST operation returns a redirection command.

Paweł Bejger
  • 6,176
  • 21
  • 26
1

You could consider redirecting the user to another web page, so that the subsequent request is made using GET.

The goal here is that the act of loading the submission action page is what causes the browser to resubmit on refresh. After all, you are literally requesting that same submission action a second time. By redirecting to another page, your request will now be done using GET, and the page that is loaded will not be the one that performs submit logic.

This is also known as the Post/Redirect/Get pattern.

David Pfeffer
  • 38,869
  • 30
  • 127
  • 202