开发者

WCF UriTemplate won't match a single string parameter with slashes (/'s)

开发者 https://www.devze.com 2022-12-22 05:05 出处:网络
Here is the scenario, I ha开发者_StackOverflow社区ve 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

Here is the scenario, I ha开发者_StackOverflow社区ve 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.

Is this possible with UriTemplate?

  • I realize that I could setup a UriTemplate like "/{directory}/{file}" but that is not an option because there is a variable number of directories.


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/
0

精彩评论

暂无评论...
验证码 换一张
取 消