in C#

Disabling Request Validation with ASP.NET MVC

Sometimes when dealing with POSTS and form data, you need to disable Request Validation to allow HTML/scripting data into your methods.   Traditionally with Web Forms you use <%@ Page ValidateRequest=”false” %> which turns off Request Validation, just be aware that this doesn’t work with ASP.NET MVC.

You apply the [ValidateInput] attribute to the controller action in order to make this happen.

1
2
3
4
5
6
7
8
9
[ValidateInput(false)]

[AcceptVerbs(HttpVerbs.Post)]

public ActionResult Create([Bind(Exclude="Id")]Product productToCreate)

{

}