I had a small bug in a view and noticed that the view engine was searching not only for my razor views but for aspx/ascx pages. (My bug is fixed)
Is there a way to tell it to only search the Razor view engine?
Here is the error message that was displayed:
The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Areas/BO/Views/Organization/Index.aspx
~/Areas/BO/Views/Organization/Index.ascx
~/Areas/BO/Views/Shared/Index.aspx
~/Areas/BO/Views/Shared/Index.ascx
~/Views/Organization/Index.aspx
~/Views/Organization/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Areas/BO/Views/Organization/Index.cshtml
~/Areas/BO/Views/Organization/Index.vbhtml
~/Areas/BO/Views/Shared/Index.cshtml
~/Areas/BO/Views/Shared/Index.vbhtml
~/Views/Organization/Index.cshtml
~/Views/Organization/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
If you have a desire to use custom extensions in your ViewEngines, and the suggestion to set the
ViewEngine.FileExtensions = new[] { "cshtml" }
doesn't work for you either, check out the related question: Make ASP.NET MVC 3 Razor View Engine ignore .vbhtml filesSpecifically my answer (or the others really) https://stackoverflow.com/a/20912185/1037948
You need to remove the
WebFormsViewEngine
fromViewEngine.Engines
so that it only contains aRazorViewEngine
.For example: