I am currently developing an MVC application in ASP.net. I am using AJAX.ActionLink to provide a delete link in a list of records, however this is very insecure. I have put
Use AntiForgeryToken with Ajax.ActionLink
In addition to jjwhite01 response;
to insert the token in Form data, use option.data
in Prefilter
$.ajaxPrefilter(
function (options, localOptions, jqXHR) {
if (options.type !== "GET") {
var token = GetAntiForgeryToken();
if (token !== null) {
if (options.data.indexOf("X-Requested-With") === -1) {
options.data = "X-Requested-With=XMLHttpRequest" + (options.data === "") ? "" : "&" + options.data;
}
options.data = options.data + "&" + token.name + '=' + token.value;
}
}
}
);