2011-10-11 36 views
8

我在视图中有一个小错误,并注意到视图引擎不仅搜索我的剃刀视图,而且寻找aspx/ascx页面。 (我的bug已修复)MVC 3 Razor - 如何停止视图引擎搜索aspx和ascx页面?

有没有办法告诉它只搜索Razor视图引擎?

这里是在显示错误消息:

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 

回答

15

您需要从ViewEngine.Engines删除WebFormsViewEngine,使其只包含RazorViewEngine

例如:

ViewEngines.Engines.Clear(); 
ViewEngines.Engines.Add(new RazorViewEngine()); 
+0

我会把这个在app_start? – Arnej65

+0

是的。 – SLaks

+0

非常感谢。 (9min直到接受) – Arnej65