WCF UriTemplate不匹配斜杠一个字符串参数(/人的) [英] WCF UriTemplate won't match a single string parameter with slashes (/'s)

查看:297
本文介绍了WCF UriTemplate不匹配斜杠一个字符串参数(/人的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是该方案,我有一个WCF服务调用,它有一个字符串参数,该字符串中有斜杠(如123 / 456.xml)。我想设置这样的UriTemplate/ {文件}这样我就可以在的 http://www.example.com/File.svc/123/456.xml 而不是的 http://www.example.com/File.svc/GetFile?file=123/456.xml

Here is the scenario, I have a WCF service call that takes one string parameter and that string has slashes in it (e.g. "123/456.xml"). I want to setup a UriTemplate like this "/{file}" so that I can access the method at http://www.example.com/File.svc/123/456.xml rather than http://www.example.com/File.svc/GetFile?file=123/456.xml.

这可能与UriTemplate?

Is this possible with UriTemplate?

  • 在我意识到,我可以建立像一个UriTemplate/ {目录} / {文件},但是这是不是一种选择,因为有一个可变数目的目录。

推荐答案

好吧,我发现MSDN上的解决方案。 UriTemplates支持通配符段基本上指的是路径的其余部分。所以,我可以指定像UriTemplate/ {*}文件,它会正常工作。

Alright, I found a solution on MSDN. UriTemplates support wildcard segments which basically mean the rest of the path. So I can specify a UriTemplate like "/{*file}" and it will work as expected.

  • MSDN docs: http://msdn.microsoft.com/en-us/library/bb675245.aspx
  • Better explanation: http://hyperthink.net/blog/uritemplate-match/

这篇关于WCF UriTemplate不匹配斜杠一个字符串参数(/人的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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