UriTemplate 通配符用于将 Uri 片段与 WCF WebGet 方法中的空格进行匹配

发布于 2024-12-19 03:00:59 字数 399 浏览 3 评论 0原文

我使用 UriTemplate 通配符来匹配 WCF svc 路径后的整个 URI 字符串:

    [WebGet(
        UriTemplate = "feed/{*path}" 
        )]

但是,这只匹配到第一个空格(或“+”或“%20”),是否可以使其匹配空格?

这有效: /feed.svc/Folder

这些不起作用(仅返回第一个空格)

/feed.svc/Folder Name

/feed.svc/Folder +名称

/feed.svc/Folder%20Name

干杯

I'm using a UriTemplate wildcard to match the whole URI string after the path to a WCF svc:

    [WebGet(
        UriTemplate = "feed/{*path}" 
        )]

However this only matches up until the first space (or '+' or '%20'), is it possible to get it to match spaces?

This works:
/feed.svc/Folder

These don't work (only returns up to the first space)

/feed.svc/Folder Name

/feed.svc/Folder+Name

/feed.svc/Folder%20Name

Cheers

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

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

发布评论

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

评论(1

ぇ气 2024-12-26 03:00:59

好吧,罪魁祸首是我制定的 IIS 重写规则:

^([0-9a-zA-Z\-\.\/()]+) 

这与空格不匹配,所以我只需将空格字符添加到正则表达式中,唉:

^([ 0-9a-zA-Z\-\.\/()]+)

Tada!

OK the culprit was the IIS rewrite rules I had in place:

^([0-9a-zA-Z\-\.\/()]+) 

This was not matching spaces so I just had to add the space character to the regex, ala:

^([ 0-9a-zA-Z\-\.\/()]+)

Tada!

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