validateRequest and requestValidationMode dont work with .net 2.0

Vivek Patel picture Vivek Patel · Apr 18, 2012 · Viewed 42.5k times · Source

I am hosting WCF Service in IIS 7. They are running under .net version 2.0. Everything is working fine. But lately, i am getting error list "Potentially Dangerous request ...". I searched on the internet and found out have i have to set my web.config like this.

<system.web>
    <httpRuntime requestValidationMode="2.0" />
    <pages validateRequest="false" />
</system.web>

I updated my web.config but then I am not able to browse to the services. It is giving me this error.

Parser Error Message: Unrecognized attribute 'requestValidationMode'. Note that attribute names are case-sensitive.

Please help me to resolve this error. Thanks, Vivek

Answer

nzduck picture nzduck · Jun 9, 2012

The requestValidationMode attribute was introduced in .NET 4.0.

Under .NET 2.0 you should only have to add <pages validateRequest="false" /> to your Web.config to avoid Potentially Dangerous request errors.

You can also turn request validation off for an individual page using <%@ Page ValidateRequest="false" %>.