Troubleshooting ASP.NET Routing on IIS 7

ASP.NET routing is pretty darn simple to set up. It works right out of the box, in most cases. However, I still ran into a few issues where accessing a route would bomb with the generic HTTP 404 exception. So after pulling my hair for a good hour, I finally resolved the issue and decided to do a quick write up on the solution.

The very first thing to check is whether the Url Routing module is even running. A quick way to make sure that it is in fact running is by setting runAllManagedModulesForAllRequests to true on the module node like shown below.

<system.webServer>  
  <modules runAllManagedModulesForAllRequests="true">
  </modules>
</system.webServer>  

This would ensure that Url Routing module will run for every HTTP request. However, this also makes every other registered managed module run for every single request and on just about any resource. So, if you application gets a lot of traffic, you might see some performance issues and should consider a workaround.

Unfortunately, this wasn’t the end of my misery. I still had the same problem and decided to dig into IIS configurations. As it turned out, I was missing an HttpRedirectionModule which, as the name suggests, does all of the magic behind URL redirects.

Fortunately, installing the module is very easy. Simply navigate to Administrative Tools on your server and fire up Server Manager. On the left-hand side, expand into Roles and Web Server then right click and select Add Role Services from the context menu.

Adding Role Services

This will open up another window. Drill down into “Common HTTP Features” and check “HTTP Redirection” as shown below. The setup wizard will automatically install and configure the module for you.

Installing HTTP Redirection feature in IIS

You should now be able to successfully access your routes.