无法传递“%26"WCF服务中的WebGet UriTemplate变量? [英] Can't pass in "%26" to a WebGet UriTemplate variable in a WCF service?

查看:70
本文介绍了无法传递“%26"WCF服务中的WebGet UriTemplate变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a WCF service with this declared operation:

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

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

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 (&).

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

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?

推荐答案

尝试使用

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

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

这篇关于无法传递“%26"WCF服务中的WebGet UriTemplate变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆