What is use of [ValidateAntiForgeryToken] in ASP.NET MVC Views

Total Post:26

 1365  View(s)
Rate this:
Hi All,

I want to know what is benefit to using [ValidateAntiForgeryToken] in above of our controller view . Here i want to give a snapshot of login partial view:

What is use of [ValidateAntiForgeryToken] in ASP.NET MVC Views

Please can anyone give me a solution.

Thank you.
  1. Post:135

    Re: What is use of [ValidateAntiForgeryToken] in ASP.NET MVC Views

    Hi Sachin,


    I have generally use  AntiForgeryToken  for prevents external get requests. So no one can access outside.

     Suppose, we are having AntiForgeryToken in our Html.BeginForm in View.


    @using (Html.BeginForm())

    When we submit form, we sends data to your Controller method. If method has ValidateAntiForgeryToken attribute, it validates if data we are sending has our  ForgeryToken.ForgeryToken is generated once per session.

    public ViewResult Action_Method()

      Modified On Mar-21-2016 12:29:09 AM



Enter your email address here always to be updated. We promise not to spam!