I really like the new .NET 4 (3.5) routing, it is very simple and straight forward to implement – just add some MapPageRoute to your global.asax and then some RouteData.Values to your aspx files
Anyway it was simple until last night when I was adding routing to an old VB.NET WebSite project. I just could not get it to work, I kept getting HTTP 404 errors:
HTTP Error 404.0 – Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Detailed Error Information
Module IIS Web Core
Error Code 0×80070002
Finally I figured out that I had some stuff missing in my web.config to get this to work, ie making sure the routing module runs.
<system.webServer> <modules> <remove name="UrlRoutingModule-4.0" /> <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" /> </modules> </system.webServer>
or use this:
<system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer>
This is probably not a problem for new projects created in Visual Studio 2010 but obviously my old web.config needed some fixing.
Thanks to this blog post by Ashic Mahtab.