我的页面有...
@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。
我错过了什么?