How to Disable Annoying Request Validation
If I summed it all up, I must have spent more than a day struggling to disable request validation with asp.net mvc. It is just ridiculously hard to disable it.
It turns out that the only way to disable it once and for all is a combination of a setting in the web.config and the ValidateRequestAttribute.
Add the following line to your web.config file right after <system.web>:
Add the [ValidateInput(false)] attribute to the controller and the action method you want to expose
Rebuild the project and go drink a beer.
Note: This is targeted to ASP.NET 4, when the requestValidationMode)/learn/whitepapers/aspnet4/breaking-changes/#_TOC7) attribute was introduced. In .NET 3.5, you can skip the first step and only do 2 and 3, but I’m not 100% positive about that.
Happy coding :)