3

I have a similar requirement which is mentioned in the link Dots in URL causes 404 with ASP.NET mvc and IIS . Our requirement is, we also do have URLs with dots in the path. For example I may have a URL such as www.example.com/people/michael.phelps (This example is taken from above link) URLs with the dot generate a 404. If we pass without the dot, then everything works. If we add the dot I get a 404 error.

The above link provide solution for earlier versions of .net where we can have webconfig files. But we are using .net core to build web API application. Dotnet core does not support webconfig files. Can someone please suggest how can we arrive at the solution by using .net core.

Nkosi
  • 235,767
  • 35
  • 427
  • 472
  • share how your routing is configured. Simple routing like `[HttpGet("/before.after")]` works fine for me. – Set Sep 27 '17 at 17:27
  • Do not forget to append trailing slash like www.example.com/people/michael.phelps/, it should work – Lukas Kubis Sep 29 '17 at 14:25
  • We use attribute routing. before.after will not work for us as we do not have idea on how many dots are present in the path. For example, dit.web.config – Jayaprakash P G Oct 05 '17 at 07:55
  • Show an example of the attribute route that fails? – Chris F Carroll Oct 10 '17 at 10:28
  • This is how we have defined our method in API controller [Route("~/api/HierarchyProperty/store/{store}/hierarchy/{*hierarchy}")] [HttpGet] public Dictionary GetByName(string store, string hierarchy) { return this.hierRep.Get(store, hierarchy); } – Jayaprakash P G Oct 12 '17 at 03:19
  • We are calling api as below http://localhost:65135/api/HierarchyProperty/store/xyz/hierarchy/dit.web.config – Jayaprakash P G Oct 12 '17 at 03:25
  • We are calling api as below and it returns 404 error http://localhost:65135/api/HierarchyProperty/store/xyz/hierarchy/dit.web.config However, if we call without any dots in between it succeeds. For eg: http://localhost:65135/api/HierarchyProperty/store/xyz/hierarchy/ditwebconfig – Jayaprakash P G Oct 12 '17 at 03:33

1 Answers1

1

Late answer but we had a similar case:

We had a url looking like https:/domain.com/somepath/smoething.cd

This returned a 404 from the IIS. Adding a / at the end of the url behind the .cd fixed the issue.

Strange but notable: not all.something return a 404, .com at the end of the path for example works

unkreativ
  • 482
  • 2
  • 8
  • Yes, I've also noticed this kind of problem. Adding a / at the end is a workaround. Since I'm using Kestrel, it doesn't seem to be an IIS Issue, also I'd like to notice, that it just doesn't match the route, but middleware after routing will still be executed. – LuckyLikey May 09 '22 at 12:30