posted on 15 January 2013


Allow a dot in Asp.Net MVC application (Specifically IIS 7+)


Quick post on something I came across the other day. We had a requirement to include a dot in the URL, something along the lines of "blah/something2.0/blah". If you try this with a brand new MVC site you would normally get a 404 HTTP response code when trying to access the URL. 

A quick google search led me to a page by Phil Haack (I love his blog posts) titled Putting the Con (COM1, LPT1, NUL, etc.) Back in your URLs. He mentioned a simple fix by adding the following to your web.config

        <httpRuntime relaxedUrlToFileSystemMapping="true"/>

Brilliant, I open my web.config, pasted in the setting and ... nothing. Still a 404? Took another look and realised that for IIS7+, you need to update the system.webServer section of your web.config. Another quick google search and I found the following snippet:

    <modules runAllManagedModulesForAllRequests="true"></modules>
    <!-- other settings -->

Browse to the url and it works.

One important thing to note about making this change is that all requests will be run through managed code. One side effect of this is authenticated pages. If you are serving CSS and JavaScript files to a login page, and those resources are secured behind authentication, then the request will be redirected to the login page (hence no resources will be served). Any request that is mapped to a physical file is usually served by IIS irrespective of authentication status (this only applies to non ASP files, e.g. images, css files, zip files etc.). Because all requests are being mapped via the ASP.NET pipeline, it will not serve content that is secured if the user is not authenticated.

Hopefully this saves someone out there an hour or two. As always, feedback welcome.


Head of Development for Cergis.

Find out more about Gordon here.


add your comment

Email me when other users reply