How to check CSRF in an ActionLink

Viewed 48

How to add an AntiForgeryToken in actionlink, I have a CRUD table and I need to check the CSRF in the delete button how can i do it ? or please to suggest any other way.

 Html.ActionLink("Delete", "Delete", "Home", new { id = row.id}   

for the creation it's easy since i'm submitting the data, so i'm doing it like this

 [HttpPost]
 [ValidateAntiForgeryToken]
 public ActionResult AddUser(UserModel req)

and in the view it's like this :

@using (Html.BeginForm("AddUser", "Home", FormMethod.Post, new { id = "newUser", @role = "form" }))
{
    @Html.AntiForgeryToken();

thanks,

0 Answers
Related