title: ASP.NET MVC 3 Beta 1 Block Access to Razor views
body: <p>Is there a way to block access (404) to the Razor views in MVC 3 beta 1? When I create a brand new blank site (IIS7) and then access /views/home/index.cshtml from the browser, instead of the 404 I get this</p>
  
  <pre><code>    [InvalidCastException: Unable to cast object of type 'ASP.Index_cshtml' to type 'System.Web.IHttpHandler'.]
     System.Web.WebPages.WebPageHttpHandler.CreateFromVirtualPath(String virtualPath, VirtualPathFactoryManager virtualPathFactoryManager) +56
     System.Web.WebPages.WebPageRoute.DoPostResolveRequestCache(HttpContextBase context) +253
     System.Web.WebPages.WebPageHttpModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +89
     System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +75
  </code></pre>
  
  <p>By default the web.config file in the views folder is set to block all file requests, but obviously this request is still getting through.</p>
  
  <p><strong>Steps to reproduce: <br /></strong>
  File -> New Project <br />
  ASP.NET MVC 3 Web Application <br />
  Internet Application (Razor) <br />
  F5<br />
  Navigate to /views/home/index.cshtml</p>