Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ValidateAntiForgeryToken attribute [duplicate]

Can someone tell me what that attribute means . How does it works ?

NortwhindEntities db=new NorthwindEntities();

[ValidateAntiForgeryToken]
public ActionResult Save(Product product)
{
  db.Product.Add(product);
  Return View();
}
like image 700
V.B. Avatar asked Dec 02 '22 21:12

V.B.


1 Answers

The ValidateAntiForgeryToken attribute is used to prevent forgery of requests. Request validation is needed to secure your MVC application. It works by adding a new 'Anti Forgery Token' hidden field to your form and a cookie; and then validating/comparing the two in a POST request. Here is an article that explains in more detail how the anti-forgery mechanism works.

like image 153
Elie Avatar answered Jan 07 '23 06:01

Elie