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="<,>,%,&,:,\,?" />