Periods in MVC urls

Written 10/23/2017


This morning I made some small changes on how my blog website works.
I had some urls looking like this:

This is how many default MVC applications are build. The integer is the identifier, which is used by a controller action, to identify some data from the database. But that doesn’t give a very user friendly url. It would be better if we could show the headline or the title of the data, pulled from the database. In my case, you probably guessed that I am pulling a blog in the first url, and a list of blogs in the second url.


I wanted to achieve user friendly and readable urls.
After some small changes of the routing, I had urls looking like this:

All the links seemed to work fine, but one. The url supposed to give all blogs, with the category id for the ASP.NET category did not work. The last part of the url (“ASP.NET”) was only cosmetic, and not used at all in my logic. I still wanted this part, as this was exactly what made my url readable. But it turned out to be exactly that part causing the problems, as the IIS doesn’t know whether the last part is a file or folder, because a dot is included.
The problem only occurs when the very last part of an MVC url includes a dot. There are different ways to handle it. The easiest, the best and the most effective is to change url strategy, by adding a slash at the end of the url.
If you are interested in other ways of handling the issue (including the IIS), please take a look at this great blog written by Scott Forsyth:

handing mvc paths with dots in the path