Can't pass "% 26" to the WebGet UriTemplate variable in the WCF service?

I have a WCF service with this declared operation:

[WebGet(UriTemplate = "Test/{*testString}")]
public String Test(String testString)
{
    return testString;
}

However, when I try to call the URL, Test/You%26MeIIS returns an error:

A potentially dangerous Request.Path value was detected from the client (&).

My goal is to allow ampersand in URI through its URL encoding:% 26

The wildcard did not help. Is there a way to prevent this error without disabling security features?

+3
source share
1 answer

Try using the RequestPathInvalidCharactersconfiguration property in Web.config, avoiding the characters used as follows:

<system.web>
   <httpRuntime requestPathInvalidCharacters="<,>,*,:,\\" />
</system.web>
+3
source

Source: https://habr.com/ru/post/1751414/


All Articles