WCF UriTemplate won't match a single string parameter with slashes (/'s)
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/
精彩评论