I've been trying for a while now to figure out why this UriTemplate does not work as part of a WCF service and can't seem to get anywhere:
[WebGet(UriTemplate="api/1.0/version")]
string GetVersion();
A quick test shows that UrlTemplateTable matches it fine (output is '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());
}
The dot is not an illegal character in URLs, RequestPathInvalidCharacters does not exclude it, there are no rewrite rules in place that could interfere. Couldn't find anything in the documentation on it either.
While there is an obvious workaround, not use the dot in the template, I'm curious as to why it fails with 'HTTP 404/The resource cannot be found'.
I ran into the same issue before. I realized it was a limitation in IIS, and nothing to do with WCF. When IIS initially intercepts the request assumes the value following the . represents an extension, so it tries to find a managed handler for that extension. Since it does not find any, it just throws a 404.
Regards Pablo.