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
This one keeps the original RazorViewEngine
and cleans away the VB extensions.
//Remove the legacy ASPX view engine
ViewEngines.Engines.Remove(ViewEngines.Engines.OfType<WebFormViewEngine>().Single());
//Remove VB from the remaining view engine
var target = ViewEngines.Engines.OfType<RazorViewEngine>().Single();
(new Expression<Func<RazorViewEngine,string[]>>[] {
y => y.FileExtensions,
y => y.ViewLocationFormats,
y => y.PartialViewLocationFormats,
y => y.MasterLocationFormats,
y => y.AreaMasterLocationFormats,
y => y.AreaPartialViewLocationFormats,
y => y.AreaViewLocationFormats
}
).Select(y => (PropertyInfo)((MemberExpression)y.Body).Member).ToList()
.ForEach(y => y.SetValue(target,((string[])y.GetValue(target))
.Where(x => x.EndsWith("cshtml")).ToArray(),null));