更新时间:2021-07-12 23:15:38
防伪标记是一种防止跨站请求伪造攻击。当使用默认的MVC方法时,它有2个部分:
Anti-forgery token is a method of preventing Cross-Site Request forgery attacks. When using default MVC methods it has 2 parts to it:
Html.AntiForgeryToken
。这会导致在表单上创建隐藏的输入字段 __ RequestVerificationToken
ValidateAntiForgeryToken
适用于您的控制器或操作方法。Html.AntiForgeryToken
. This causes hidden input field __RequestVerificationToken
to be created on a formValidateAntiForgeryToken
applied to your controller or action methods.在您的情况下,错误表示您有 ValidateAntiForgeryToken
关于你的方法,但表单方法没有提交第二部分 - 字段 __ RequestVerificationToken
。为了解决这个问题,你应该在post方法中添加第二个参数:
In your case error indicates that you have ValidateAntiForgeryToken
on your method, but the form method did not submit the second part - field __RequestVerificationToken
. In order to fix that you should add a second parameter to your post method:
var params = "&agency_id=" + id;
params += params + "&__RequestVerificationToken=" + $('input[name=__RequestVerificationToken]').val();
$.ajax({
url: funcs,
type: "POST",
data: params,
})
您可以在此博客文章