2
votes

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?

2

2 Answers

5
votes

Add the following line of code:

GlobalFilters.Filters.Add(new ValidateInputAttribute(false));

to the Application_Start() method.

3
votes

Add [AllowHtml] to the action, parameter, or property.

EDIT: If you want to allow it anywhere, add new ValidateInputAttribute(false)] to GlobalFilters.Filters.