我的页面有...
@page "{candidateId:int}"
...和
@Html.AntiForgeryToken()
模型具有...
public void OnGet(int candidateId)
{
}
public void OnPost(int candidateId)
{
}
GET请求正常。这是我的AJAX请求...
$.ajax({
type: "POST",
url: "/Skills/" + candidateId,
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
data: {
name: 'hi mum'
},
success: function (response) {
},
failure: function (response) {
alert(response);
}
});
浏览器接收到无用的错误信息... 400 Bad Request。
我错过了什么?
__RequestVerificationToken
的隐藏输入? - Shyju