Blog Stats
  • Posts - 9
  • Articles - 0
  • Comments - 5
  • Trackbacks - 0

 

ASP.NET 4.0 URL Routing HTTP Error 404.0 - Not Found

URL Routing is a very nice new feature in ASP.NET 4.0. And in Visual Studio everything works just great. But as soon as you start testing on IIS you get a "Error 404.0 - Not Found".

To solve this you need to make sure that:

  1. you have set the Application Pool to "asp.net 4.0 application pool". Routing will not work with "asp.net 4.0 classic application pool".
  2. you add the following code to your web.config:

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="UrlRoutingModule"/>
      <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0,
                               Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </modules>
    <handlers>
      <add
        name="UrlRoutingHandler"
        preCondition="integratedMode"
        verb="*" path="UrlRouting.axd"
        type="System.Web.HttpForbiddenHandler, System.Web, 
              Version=2.0.0.0, Culture=neutral, 
              PublicKeyToken=b03f5f7f11d50a3a"/>
    </handlers>
  </system.webServer>

Routing should work in IIS as well now. Hope it helps.


Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

 

 

Copyright © Ben Bastiaensen