无法传入“%26”到 WCF 服务中的 WebGet UriTemplate 变量?

发布于 2024-09-07 06:08:34 字数 423 浏览 2 评论 0原文

我有一个具有此声明操作的 WCF 服务:

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

但是,当尝试调用 URL Test/You%26Me 时,IIS 返回错误:

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

我的目标是通过其 URL 编码在 URI 中允许使用 & 符号: %26

通配符没有帮助。有没有什么方法可以在不禁用安全功能的情况下防止此错误?

I have a WCF service with this declared operation:

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

However when attempting to invoke the URL Test/You%26Me, IIS returns an error:

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

My goal is to allow an ampersand in the URI via its URL-Encoding: %26

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻的心爱 2024-09-14 06:08:34

尝试使用 RequestPathInvalidCharacters Web.config 中的 配置属性避免使用字符,如下所示:

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

Try using RequestPathInvalidCharacters configuration property in Web.config avoiding used characters as follows:

<system.web>
   <httpRuntime requestPathInvalidCharacters="<,>,*,:,\\" />
</system.web>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文