【发布时间】:2011-09-13 03:35:09
【问题描述】:
我有一个使用经典 Web 表单视图的旧 ASP.NET MVC 应用程序。作为一个实验,我们已经开始混合一些剃刀视图。不幸的是,在哪里可以找到所需视图的默认优先级不是我想要的。 MVC 首先在 /Views/ControllerName 文件夹中查找 aspx 和 ascx 文件。然后它移动到您的 /Views/Shared 以获取 aspx 和 ascx 文件。然后它开始寻找 .cshtml 和 .vbhtml 文件。我想要的是它在用尽 /Views/ControllerName 文件夹中的所有可能性之前不要进入 Shared 文件夹。我该怎么做?
--- 更新 ---
这里有一些额外的信息可能有助于解释我所追求的。默认情况下,我得到这个搜索顺序:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
我想要的是这个:
~/Views/Home/Index.aspx
~/Views/Home/Index.ascx
~/Views/Home/Index.cshtml
~/Views/Home/Index.vbhtml
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml
换句话说,它不应该在完全搜索 /Views/ControllerName 文件夹之前搜索 Shared。
【问题讨论】:
标签: c# asp.net-mvc-3 razor