I have long been trying to find out why this UriTemplate is not working as part of the WCF service and cannot seem to go anywhere:
[WebGet(UriTemplate="api/1.0/version")] string GetVersion();
A quick test shows that UrlTemplateTable matches it exactly (output: "api / 1.0 / version"):
static void Main(string[] args) { Uri prefix = new Uri("http://localhost/"); System.UriTemplateTable table = new System.UriTemplateTable(prefix); table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(new UriTemplate("api/1.0/version"), "a")); table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(new UriTemplate("api/2.0/version"), "b")); table.KeyValuePairs.Add(new KeyValuePair<UriTemplate, Object>(new UriTemplate("api/version"), "c")); Uri uri = new Uri("http://localhost/api/1.0/version"); UriTemplateMatch match = table.MatchSingle(uri); Console.WriteLine("{0}", match.Template.ToString()); }
A dot is not an illegal character in URLs; RequestPathInvalidCharacters elements do not exclude it; there are no rewriting rules that can interfere. Could not find anything in the documentation on it.
While there is an obvious workaround, do not use a period in the template, I am curious why this happens with "HTTP 404 / Resource not found".
source share