title: Can ASP.NET Routing be used to create "clean" URLs for .ashx (IHttpHander) handlers?
body: <p>I have some REST services using plain old <code>IHttpHandler</code>s.  I'd like to generate cleaner URLs, so that I don't have the .ashx in the path.  Is there a way to use ASP.NET routing to create routes that map to ashx handlers?  I've seen these types of routes previously:</p>
  
  <pre><code>// Route to an aspx page
  RouteTable.Routes.MapPageRoute("route-name",
      "some/path/{arg}",
      "~/Pages/SomePage.aspx");
  
  // Route for a WCF service
  RouteTable.Routes.Add(new ServiceRoute("Services/SomeService",
      new WebServiceHostFactory(),
      typeof(SomeService)));
  </code></pre>
  
  <p>Trying to use <code>RouteTable.Routes.MapPageRoute()</code> generates an error (that the handler does not derive from <code>Page</code>).  <code>System.Web.Routing.RouteBase</code> only seems to have 2 derived classes: <code>ServiceRoute</code> for services, and <code>DynamicDataRoute</code> for MVC.  I'm not sure what <code>MapPageRoute()</code> does (Reflector doesn't show the method body, it just shows "Performance critical to inline this type of method across NGen image boundaries").</p>
  
  <p>I see that <code>RouteBase</code> is not sealed, and has a relatively simple interface:</p>
  
  <pre><code>public abstract RouteData GetRouteData(HttpContextBase httpContext);
  
  public abstract VirtualPathData GetVirtualPath(RequestContext requestContext,
      RouteValueDictionary values);
  </code></pre>
  
  <p>So perhaps I can make my own HttpHandlerRoute.  I'll give that a shot, but if anyone knows of an existing or built-in way of mapping routes to IHttpHandlers, that would be great.</p>