title: Disable Razors default .cshtml handler in a ASP.NET Web Application
body: <p>Does anyone know how to disable the .cshtml extension completely from an ASP.NET Web Application?</p>
  
  <p>In essence I want to hijack the .cshtml extension and provide my own implementation based on a <a href="http://razorengine.codeplex.com/" rel="nofollow">RazorEngine</a> host, although when I try to access the page.cshtml directly it appears to be running under an existing WebPages razor host that I'm trying to disable.</p>
  
  <blockquote>
    <p>Note: it looks like its executing 
    .cshtml pages under the
    System.Web.WebPages.Razor context
    as the Microsoft.Data
    Database is initialized. I don't even
    have any Mvc or WebPages dlls
    referenced, just System.Web.dll and a
    local copy of System.Web.Razor with
    RazorEngine.dll</p>
  </blockquote>
  
  <p>I've created a new ASP.NET Web .NET 4.0 Application and have tried to clear all buildProviders and handlers as seen below:</p>
  
  <pre><code>&lt;system.web&gt;
      &lt;httpModules&gt;
          &lt;clear/&gt;
      &lt;/httpModules&gt;
      &lt;compilation debug="true" targetFramework="4.0"&gt;
          &lt;buildProviders&gt;
              &lt;clear/&gt;
          &lt;/buildProviders&gt;
      &lt;/compilation&gt;
  
      &lt;httpHandlers&gt;
          &lt;clear/&gt;
          &lt;add path="*" type="MyHandler" verb="*"/&gt;
      &lt;/httpHandlers&gt;
  &lt;/system.web&gt;
  
  &lt;system.webServer&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"&gt;
          &lt;clear/&gt;
      &lt;/modules&gt;
      &lt;handlers&gt;
          &lt;clear/&gt;
          &lt;add path="*" name="MyHandler" type="MyHandler" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" /&gt;
      &lt;/handlers&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>Although even with this, when I visit any <strong>page.cshtml</strong> page it still bypasses My wildcard handler and tries to execute the page itself.</p>
  
  <p>Basically I want to remove all traces of .cshtml handlers/buildProviders/preprocessing so I can serve the .cshtml pages myself, anyone know how I can do this?</p>