We have a requirement to have a dot midway in a route for one of our web api services. The route looks something like http://localhost/api/some.route/person
. The controller (if using attribute based routing) is:
1 2 3 4 5 6 7 8 9 |
|
When you try to hit this resource using fiddler or postman, you’ll get a 404 not found error. There are plenty of StackOverflow posts out there about having dots in the route but these mainly are to do with a dot at the end of the route rather than midway so something like http://localhost/api/someroute/per.son
. IIS will identify the dot and assume you are after a static file with an extension of ‘son’. To get around this, you can add this to your web.config file as explained by Phil Haack.
1 2 |
|
However this will not work where the dot is midway in the URL like I have. For me, adding the following resolves the issue (although not having to have a dot in the route would be the obvious solution but sometimes your hands are tied).
1 2 3 |
|
Adding this post as I KNOW I will forget this!