Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

validateRequest and requestValidationMode dont work with .net 2.0

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

like image 360
Vivek Patel Avatar asked Apr 18 '12 18:04

Vivek Patel


2 Answers

If you find requestValidationMode="2.0" in your web.config, it is very likely that the developer has been targeting against framework 4.0 or higher and you should probably set the application pool to the corresponding version, rather than change the settings.

like image 139
R. Schreurs Avatar answered Oct 05 '22 17:10

R. Schreurs


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" %>.

like image 41
nzduck Avatar answered Oct 05 '22 17:10

nzduck