Reputation: 66604
How do I disable this page validation entirely and for good in ASP.NET MVC 3?
I have looked through the error message and the other questions with the same title. None of the suggested solutions help:
I do have a
<httpRuntime requestValidationMode="2.0" />
in the <system.web>
section in Web.config
.
I also do have a validateRequest="false"
attribute on the <pages>...</pages>
element.
But I am still getting the error. What else can I try?
Upvotes: 2
Views: 4035
Reputation: 66604
Add the following line of code:
GlobalFilters.Filters.Add(new ValidateInputAttribute(false));
to the Application_Start()
method.
Upvotes: 5
Reputation: 888243
Add [AllowHtml]
to the action, parameter, or property.
EDIT: If you want to allow it anywhere, add new ValidateInputAttribute(false)]
to GlobalFilters.Filters
.
Upvotes: 3