Disabling .cshtml extension

Jun 25, 2011 at 7:12 PM


Does anyone know how to disable the .cshtml extension completely from an ASP.NET Web Application?

I want to try hijack the .cshtml extension to provide my own implementation based on RazorEngine, but when I try to access the page.cshtml directly it appears that 

I've created a new ASP.NET Web .NET 4.0 Application and have tried to clear all buildProviders and handlers as seen below:

		<compilation debug="true" targetFramework="4.0">

			<add path="*" type="MyHandler" verb="*"/>

		<modules runAllManagedModulesForAllRequests="true"/>
			<add path="*" name="MyHandler" type="MyHandler" verb="*" preCondition="integratedMode" resourceType="Unspecified" allowPathInfo="true" />

But no matter what I do, when I visit any page.cshtml page it bypasses My wildcard handler completely and looks like its running the .cshtml page under the System.Web.WebPages.Razor context seeing that 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

Basically I want to remove all traces of .cshtml handlers/preprocessing so I can serve the .cshtml pages myself, anyone know how to do this?

Jun 27, 2011 at 2:04 PM

Have you removed it using the



You'll have to add back the ViewEngines you want to use such as the WebFormsViewEngine. But that should remove ".cshtml"