title: Route for root address in asp.net web forms
body: <p>i have following RegisterRoutes method in global.asax of my web forms application`</p>
  
  <pre><code>routes.MapPageRoute("about", "about", "~/about.aspx");
              routes.Add(
              "root",
              new Route("", new RootRouteHandler())
              );
  </code></pre>
  
  <p>The first route works ok i.e when i type <code>http://localhost:9898/about</code> but when i go to root address like 'http://localhost:9898' it does not invoke <code>RootRouteHandler</code>. this is the code for route handler </p>
  
  <pre><code>public class RootRouteHandler : IRouteHandler
      {
          public IHttpHandler GetHttpHandler(RequestContext requestContext)
          {
              var address = requestContext.HttpContext.Request.Headers["host"];
              string host = string.Empty;
              var index = address.IndexOf('.');
              if(index&gt;0)
              {
                  host = address.Substring(0, index);
              }
              var virtualPath = string.Format("~/{0}/default.aspx", host);
              var page = BuildManager.CreateInstanceFromVirtualPath(virtualPath, typeof(Page)) as Page;
              return page;
          }
      }
  </code></pre>
  
  <p>*<em>Edit:</em>*when i add route like </p>
  
  <pre><code>routes.Add("root",new Route("default",new RootRouteHandler());
  </code></pre>
  
  <p>then the handler is called fine for the address <code>http://localhost:9898/default</code> but i need to get it working for root address. any ideas?</p>