Add AntiForgeryToken to all operations
Add AntiForgeryToken to all operations
shuminliu
Posts: 14Questions: 6Answers: 0
I'd like to add AntiForgeryToken to all the CRUD calls to the server to prevent CSRF. I'm wondering if it's possible to inject a token to the POST, either in the ajax config, or in the DataTable config.
Thanks!
$('#my-data-table').DataTable({
dom: "Blfrtip",
responsive: true,
ajax: {
url: "/api/ProcessData",
type: "POST"
},
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use
ajax.data
.Kevin
Got it. Thanks!
$('#my-data-table').DataTable({
dom: "Blfrtip",
responsive: true,
ajax: {
url: "/api/ProcessData",
type: "POST",
data: {"__RequestVerificationToken": the_token}
},