title: Configuring IIS 7 & ASP.NET App for URL Routing
body: <p>This is not an MVC topic.
  I have an ASP.NET Application which performs URL Routing in the <code>Application_Start</code> method.</p>
  
  <p>The routing looks like:</p>
  
  <pre><code>RouteTable.Routes.Add(new Route(
    "Profile/{query}",
    new RouteValueDictionary() { {"query",string.Empty} },
    new GenericRouteHandler("~/ProfileHttpHandler.ashx")
  ));
  </code></pre>
  
  <p>A <code>GenericRouteHandler</code> looks implements <code>GetHttpHandler</code> with:</p>
  
  <pre><code>var page= (IHttpHandler)BuildManager.CreateInstanceFromVirtualPath(_virtualPath, typeof(IHttpHandler));
  ...
  return page;
  </code></pre>
  
  <p>And ProfileHttpHandler.ashx is just a Visual Studio template.  It sets Content-type to "text/plain" and writes "hello world."</p>
  
  <p>This application works correctly while debugging in Visual Studio (on the ASP.NET development server). A <code>GET http://localhost:59474/Profile/abc123</code> routes to the http handler as expected.</p>
  
  <p>However, when this app is published to a remote machine running IIS 7 in Integrated Pipeline mode, the process fails.  I get HTTP 500 errors when attempting to GET anything inside the apps folder, including Default.aspx.</p>
  
  <p>Web.Config is configured as such:</p>
  
  <pre><code>&lt;system.web&gt;
    &lt;httpModules&gt;
      &lt;add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
    &lt;/httpModules&gt;
  &lt;/system.web&gt;
  &lt;system.webServer&gt;
    &lt;modules runAllManagedModulesForAllRequests="true"&gt;
      &lt;add name="RoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web.Routing, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/&gt;
    &lt;/modules&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>Lastly; I'm unsure whether this is relevant information.  In my web service provider's control panel, I have the directory which this application resides in configured as a virtual directory.
  It has the properties:</p>
  
  <ul>
  <li>mydomain.ca/routeapp: Folder in your Hosting Space (domain.ca\wwwroot\routeapp)</li>
  <li>Allow Anonymous Access: On.</li>
  <li>Enable Integrated Windows Authentication: On.</li>
  <li>Enable Basic Authentication: On.</li>
  <li>ASP: Disabled.</li>
  <li>ASP.NET: 2.0 Integrated Pipeline.</li>
  <li>PHP: Disabled.</li>
  <li>Perl: Enabled.</li>
  </ul>