How can I remove the VB Razor Engine or configure the RazorViewEngine to not use and look for .vbhtml files on disk? For new ASP.NET MVC 3 Razor projects, I always remove th
Why is there no point in removing search in .vbhtml if I'm never going to use it?
Here is how I do it (but I still don't know is it a good thing to remove vbhtml):
protected void Application_Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine().DisableVbhtml());
...
}
Extension method code:
public static RazorViewEngine DisableVbhtml(this RazorViewEngine engine)
{
engine.AreaViewLocationFormats = FilterOutVbhtml(engine.AreaViewLocationFormats);
engine.AreaMasterLocationFormats = FilterOutVbhtml(engine.AreaMasterLocationFormats);
engine.AreaPartialViewLocationFormats = FilterOutVbhtml(engine.AreaPartialViewLocationFormats);
engine.ViewLocationFormats = FilterOutVbhtml(engine.ViewLocationFormats);
engine.MasterLocationFormats = FilterOutVbhtml(engine.MasterLocationFormats);
engine.PartialViewLocationFormats = FilterOutVbhtml(engine.PartialViewLocationFormats);
engine.FileExtensions = FilterOutVbhtml(engine.FileExtensions);
return engine;
}
private static string[] FilterOutVbhtml(string[] source)
{
return source.Where(s => !s.Contains("vbhtml")).ToArray();
}