I am only using RazorViewEngine on one of my ASP.NET MVC 3 applications and I cleared Web Forms view engine out with following code inside Application_Start method of my Global.asax.cs file
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
I decided to see something solid so that I could be satisfied with this two-line-code-effort and I try to render a partial view which does not exist and I got this result :
The partial view ‘_ResortMapPartialView’ was not found or no view
engine supports the searched locations. The following locations were
searched:
~/Areas/Accommodation/Views/resort/_ResortMapPartialView.cshtml
~/Areas/Accommodation/Views/resort/_ResortMapPartialView.vbhtml
~/Areas/Accommodation/Views/Shared/_ResortMapPartialView.cshtml
~/Areas/Accommodation/Views/Shared/_ResortMapPartialView.vbhtml
~/Views/resort/_ResortMapPartialView.cshtml
~/Views/resort/_ResortMapPartialView.vbhtml
~/Views/Shared/_ResortMapPartialView.cshtml
~/Views/Shared/_ResortMapPartialView.vbhtml
It looks a little better. Now it looks for less items than before. But still the files with .vbhtml extensions are making me unconformable.
The question is that : How can we get rid of them?
My suggestion would be to override the
RazorViewEnginedefinitions for the following to only includecshtmlfiles.An brief example:
}
See my answer which talks about overriding these values. The same principle applies. You will need to register this modified ViewEngine (
CSHtmlViewEngine) in theApplicationStartmethod