All ASP.NET MVC Forms Need To Include Html.AntiForgeryToken() For Security!!!!!

Posted on

Having recently been implementing many new form pages in ASP.NET MVC, I’ve found myself over and over again adding the following two things to every form.

  • After Html.BeginForm() I Put @Html.AntiForgeryToken()
  • Add the Attribute [ValidateAntiForgeryToken] To Every Post Action Method

Before I was doing so much ASP.NET MVC, I would often see in Channel 9 videos, the presenter add the AntiForgeryToken() after the BeginForm() method on the cshtml razor page and say something like “you should always add this”.  I never saw them say “and don’t forget to add the attribute ValidateAntiForgeryToken to the controller POST method.

To read more about this, click here:

http://peterkellner.net/2014/05/19/asp-net-mvc-forms-need-include-html-antiforgerytoken-security/?utm_source=rss&utm_medium=rss&utm_campaign=asp-net-mvc-forms-need-include-html-antiforgerytoken-security

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s