How do I prevent the user from posting the same data to the action multiple times if they keep clicking the submit button?
I know in php, there is a way to prevent this multiple submission, but I do not see any for asp.net mvc. Is there any?
You could disable the submit button using javascript. Example with jQuery:
$(function() {
$('form').submit(function() {
$('#idofsubmitbutton').attr('disabled', 'disabled');
});
});
Note however that this might not be 100% reliable as for example the user could have javascript disabled or even worse: he could have malicious intents and automate HTTP POST requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With