Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web API: A potentially dangerous Request.Path value was detected from the client [duplicate]

Tags:

So I have one endpoint on my ASP.NET Web API project that needs to accept special characters (such as %, <, >) to validate the uniqueness of a name within the system. So for the following route:

[Route("~/api/case/{name}/infosys/{system}")]

... {name} may contain a special character. For this endpoint only is there a way that I can tell Web API to allow special characters and not give this error:

HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (%).

Note: This is a Web API project so the [ValidateInput(false)] and [AllowHtmlAttribute] decorators are not available. Also, I don't want to loosen this restriction on any other endpoint by modifying my Web.config:

No
<httpRuntime requestValidationMode="2.0" />

...

No
<pages validateRequest="false">

...

No
<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,%,&amp;,:,\,?" />
like image 327
Oliver Spryn Avatar asked Apr 07 '16 19:04

Oliver Spryn


1 Answers

I tested this piece of code and it works:

httpRuntime targetFramework="4.5.1" requestPathInvalidCharacters="&lt;,&gt;,*,%,&amp;,\,?" 
like image 187
enraged Avatar answered Oct 04 '22 22:10

enraged