Ajax调用在页面加载中发送伪造令牌。
library(dplyr)
df1 %>%
group_by(id) %>%
summarise(value = sum(value), freq = n())
控制器动作就像这样
@{
ViewBag.Title = "Home Page";
}
@Html.AntiForgeryToken();
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var token = $('input[name="__RequestVerificationToken"]').val();
$.ajax({
headers: {
'__RequestVerificationToken': token
},
url: "Test",
type: "POST",
contentType: "application/json",
dataType: "json",
data: {
'__RequestVerificationToken': token
},
success: function (results) {
//alert(url);
alert("Success");
},
error: function (e) {
alert(e.responseText);
}
});
});
</script>
错误是 - 所需的防伪标记为空。