Extreme makeover: routing edition

This was going to be a full on post, but it appears the next preview of the MVC bits will do a good chunk of what I was writing up.  So for posterity, here's the general routing flow in the current ASP.NET MVC release:

  1. Define your routes in RouteTable
  2. PostResolveRequestCache event in the UrlRoutingModule passes every request to the RoutingTable to determine the relevant route
  3. If a route matches, an IRouteHandler is created
  4. The IRouteHandler gets the appropriate IHttpHandler for the specified route, passing along a RequestContext object (which contains RouteData)
    1. Default IRouteHandler uses ControllerName + Action format and reflection
  5. IHttpHandler and original path are stored in an internal RequestData object, which is appended to the context.Items collection
  6. Path is rewritten to ~/Mvc.axd
  7. PostMapRequestHandler event in the UrlRoutingModule grabs the RequestData from the Items collection, rewrites the path back to the original path and sets the IHttpHandler from step 4 to the context.Handler property
  8. Profit!