在此处查看这篇文章,了解如何处理传递给 WCF 服务的实体键中的特殊字符。
在您的情况下需要注意的是,关闭请求过滤并不能防止反斜杠被破坏:
<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0"/>
<pages validateRequest="false"/>
斜杠和问号是有问题的,因为底层的 URI 解析器正在对原始 URI 进行转义......这是这三个字符的解决方法:
<configSections>
<section name="uri" type="System.Configuration.UriSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</configSections>
<uri>
<schemeSettings>
<add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
<add name="https" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
</schemeSettings>
</uri>
(也公然从文章中窃取。)