What methods are available to stop multiple postbacks of a form in ASP.NET MVC?

后端 未结 6 1489
后悔当初
后悔当初 2020-12-12 19:48

A common web problem is where a user clicks the submit button of a form multiple times so the server processes the form more than once. This can also happen when a user hit

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 20:25

    You should always return a redirect as the HTTP response to a POST. This will prevent the POST from occuring again when the user navigates back and forth with the Forward/Back buttons in the browser.

    If you are worried about users double-clicking your submit buttons, just have a small script disable them immediately on submit.

提交回复
热议问题