我在 View 中有一个小错误,我注意到 View 引擎不仅在搜索我的 razor View ,还在搜索 aspx/ascx 页面。 (我的错误已修复)
有没有办法告诉它只搜索 Razor View 引擎?
这是显示的错误消息:
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
最佳答案
您需要从 ViewEngine.Engines
中删除 WebFormsViewEngine
,以便它只包含一个 RazorViewEngine
。
例如:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
关于c# - MVC 3 Razor - 如何阻止 View 引擎搜索 aspx 和 ascx 页面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7727259/