WebGet UriTemplate fails at point ('.' /% 2E)?

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".

+4
source share
1 answer

I used to come across the same question. I realized that this is a limitation in IIS, and has nothing to do with WCF. When IIS first intercepts the request, it takes on the value following. is an extension, so it tries to find a managed handler for this extension. Since he does not find, he simply throws 404.

Relationship Pablo.

+3
source

Source: https://habr.com/ru/post/1389414/


All Articles