I have an ajax script which calls method with following parameters.
[HttpPost]
[Authorize(Roles ="Klient")]
[ValidateAntiForgeryToken]
public ActionResult ChangeHouseParticipants(string houseName, List<Participant> participants)
{
return View();
}This script presents in that way.
for (var i = 0; i < list.length; i+=3) {
jsonArray.push({ Name: list[i].value, Surname: list[i+1].value, BirthDate: list[i+2].value });
}
var data = JSON.stringify({
houseName: $('select[name="SelectedHousesParticipants"]').val(),
participants: jsonArray,
});$.ajax({
type: "POST",
url: "/ClientReservations/ChangeHouseParticipants",
data: data,
headers: {
'__RequestVerificationToken': $("[name='__RequestVerificationToken']").val()
},
contentType: "application/json; charset=utf-8",
success: function (response) {$('assignedParticipants').html(response)
},
}
});I thought that adding field with token into headers section would solve the issuse. But I still got the message that__RequestVerificationToken is not present. Any proposals, How to solve it?