MVC 3剃须刀 - 如何从搜索ASPX和ASCX页停止视图引擎? [英] MVC 3 Razor - How to stop the view engine from searching the aspx and ascx pages?
本文介绍了MVC 3剃须刀 - 如何从搜索ASPX和ASCX页停止视图引擎?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个视图中的小bug,并注意到视图引擎不仅为我的剃须刀意见,但对于ASPX / ASCX页面搜索。 (我的错误是固定的)
有没有办法告诉它只能搜索的Razor视图引擎?
下面是已显示错误消息:
视图索引或它的主人没有被发现或没有视图引擎支持搜索位置。在以下地点被搜查:
〜/地区/ BO /查看/组织/的Index.aspx
〜/地区/ BO /查看/组织/ Index.ascx
〜/地区/ BO /查看/共享/的Index.aspx
〜/地区/ BO /查看/共享/ Index.ascx
〜/查看/组织/的Index.aspx
〜/查看/组织/ Index.ascx
〜/查看/共享/的Index.aspx
〜/查看/共享/ Index.ascx
〜/地区/ BO /查看/组织/ Index.cshtml
〜/地区/ BO /查看/组织/ Index.vbhtml
〜/地区/ BO /查看/共享/ Index.cshtml
〜/地区/ BO /查看/共享/ Index.vbhtml
〜/查看/组织/ Index.cshtml
〜/查看/组织/ Index.vbhtml
〜/查看/共享/ Index.cshtml
〜/查看/共享/ Index.vbhtml
解决方案
您需要删除 WebFormsViewEngine
从 ViewEngine.Engines
,使其只包含 RazorViewEngine
。
例如:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(新RazorViewEngine());
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
解决方案
You need to remove the WebFormsViewEngine
from ViewEngine.Engines
so that it only contains a RazorViewEngine
.
For example:
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
这篇关于MVC 3剃须刀 - 如何从搜索ASPX和ASCX页停止视图引擎?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文