ASP.NET 4.5 MVC 4 not working on Windows Server 2008 IIS 7

Solution 1:

Try using this:

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

EDIT:

The solution above will work for .NET 3.5 or below. If you are using .NET 4.0 or above, you might want to try installing IIS7 QFE

Also, this article is worth reading to understand the difference between those two.

Solution 2:

If you are not able to apply the QFE from kb 980368, instead of using the runAllManagedModulesForAllRequests solution as suggested in the accepted answer, you should use the modules configuration with preCondition="" shown below to avoid the negative impact on static content as described in the blog posts How asp.NET MVC Routing Works and its Impact on the Performance of Static Requests and Don't use runAllManagedModulesForAllRequests="true" when getting your MVC routing to work and some of the comments on the answers.

Scott Hanselman's blog post about runAllManagedModulesForAllRequests should add some weight to this argument. Rick Strahl's post Caveats with the runAllManagedModulesForAllRequests in IIS 7/8 is the best explanation of the interaction between the settings I have found. The IIS documentation on the module preCondition attribute is also worth a read.

Remember this configuration change is not necessary if you have applied the QFE as this behaviour becomes the default.

<system.webServer>
  <modules>
    <remove name="UrlRoutingModule-4.0" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  </modules>
</system.webServer>