Search code examples
asp.netasp.net-4.0

ValidateRequest=“false” and .NET 4 problem


.NET 4 broke ValidateRequest=“false” for some reason.

The solution is -- just put <httpRuntime requestValidationMode="2.0" /> into your web.config file.

The problem with that solution is that it breaks support for .NET 2.0!

IIS refuses to accept unknown attributes in web.config. Also I don't like the all or nothing nature of this.

Can I set requestValidationMode (or in some other way disable request validation) for a single page that needs it? Without breaking backwards compatibility of web.config with 2.0?


Solution

  • OK, looks like this can't be done and I can just escape the data easily, but I think this was a legitimate question -- at least to make a note here that this can't be done.