title: Asp.net Routing wrong MIME type for .css files served with UrlRoutingModule and PageBuildProvider
body: <p>I need to route request like:</p>
  
  <ul>
  <li><a href="http://www.site.com/channel1/somestring" rel="nofollow">http://www.site.com/channel1/somestring</a></li>
  <li><a href="http://www.site.com/channel1/otherstring" rel="nofollow">http://www.site.com/channel1/otherstring</a></li>
  <li><a href="http://www.site.com/channel2/anotherstring" rel="nofollow">http://www.site.com/channel2/anotherstring</a> </li>
  </ul>
  
  <p>to my default page: <a href="http://www.site.com/default.aspx" rel="nofollow">http://www.site.com/default.aspx</a> page</p>
  
  <p>for a web project that runs on .net 4.5, IIS Express with integrated pipeline.</p>
  
  <p><strong>Routes:</strong></p>
  
  <pre><code>protected virtual void RegisterRoutes()
  {
      RouteTable.Routes.MapPageRoute("AliasCss","{channel}/css/{*url}","~/css/{url}",
           false,null, new RouteValueDictionary { { "channel", "(channel1|channel2)"}});
  
      RouteTable.Routes.Ignore("{resource}.js");
      RouteTable.Routes.Ignore("{resource}.css");
  
      RouteTable.Routes.MapPageRoute("Alias", "{*url}", "~/Default.aspx", true, 
          new RouteValueDictionary { { "url", "Default.aspx" } }, 
          new RouteValueDictionary { { "url", "(channel1|channel2)" } });
  }
  </code></pre>
  
  <p>It works great except for the css files</p>
  
  <blockquote>
    <p>Example: <a href="http://www.site.com/channel1/css/custom.css" rel="nofollow">http://www.site.com/channel1/css/custom.css</a></p>
  </blockquote>
  
  <p>that gives 404 error insted of serving the css files in <a href="http://www.site.com/css/custom.css" rel="nofollow">http://www.site.com/css/custom.css</a></p>
  
  <p>To solve this I needed to add a <code>PageBuildProvider</code> for making Asp.net serve static .css files and set <code>runAllManagedModulesForAllRequests="true"</code></p>
  
  <p><strong>web.config relevant parts:</strong></p>
  
  <pre><code>&lt;configuration&gt;
      ...
      &lt;system.web&gt;
          &lt;compilation debug="true" targetFramework="4.5" &gt;
              &lt;buildProviders&gt;
                  &lt;add extension=".css" type="System.Web.Compilation.PageBuildProvider" /&gt;
              &lt;/buildProviders&gt;
          &lt;/compilation&gt;
          &lt;httpRuntime targetFramework="4.5" enableVersionHeader="false"  /&gt;
          ...
      &lt;/system.web&gt;
      &lt;system.webServer&gt;
          &lt;validation validateIntegratedModeConfiguration="true" /&gt;
          &lt;modules runAllManagedModulesForAllRequests="true"&gt;
              &lt;add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule,System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"  /&gt;
          &lt;/modules&gt;
          ...
      &lt;/system.webServer&gt;
      ...
  &lt;/configuration&gt;
  </code></pre>
  
  <p>Now .css files are correctly routed but <strong>are served with wrong MIME type</strong>:</p>
  
  <blockquote>
    <p>Resource interpreted as Stylesheet but transferred with MIME type
    text/html</p>
  </blockquote>
  
  <p>I tried to set the mimetype in web.config but with no luck:</p>
  
  <pre><code>&lt;staticContent&gt;
      &lt;remove fileExtension=".css" /&gt;
      &lt;mimeMap fileExtension=".css" mimeType="text/css; charset=UTF-8" /&gt;
  &lt;/staticContent&gt;
  </code></pre>