在asp.net MVC应用程序prevent多个POST [英] Prevent multiple POST in asp.net mvc application

查看:155
本文介绍了在asp.net MVC应用程序prevent多个POST的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何prevent来自同一数据多次发布到操作的用户,如果他们继续点击提交按钮?

How do I prevent the user from posting the same data to the action multiple times if they keep clicking the submit button?

我知道在PHP中,有一种方法,以prevent此多提交,但我没有看到任何的asp.net的MVC。有没有?

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?

推荐答案

您可以禁用使用javascript提交按钮。使用jQuery例如:

You could disable the submit button using javascript. Example with jQuery:

$(function() {
    $('form').submit(function() {
        $('#idofsubmitbutton').attr('disabled', 'disabled');
    });
});

不过请注意,这可能不是100%可靠的,例如用户可以禁用了Javascript或者更糟:他可能有恶意的意图和自动化的HTTP POST请求

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.

这篇关于在asp.net MVC应用程序prevent多个POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆