Geeks With Blogs
Ben Bastiaensen Living the .NET live

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.

Posted on Thursday, April 21, 2011 4:42 AM ASP.NET | Back to top


Comments on this post: ASP.NET 4.0 URL Routing HTTP Error 404.0 - Not Found

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Ben Bastiaensen | Powered by: GeeksWithBlogs.net