【发布时间】:2013-02-18 18:31:18
【问题描述】:
有谁知道 _ViewStart.cshtml 没有被 MVC 3 中的自定义 ViewEngine 选中的原因吗?
我的观点现在在
~\UI\视图\
~\UI\Views\共享\
ViewStart 位于 ~\UI\Views_ViewStart.cshtml。
我已经清除了现有的 RazorViewEngine 并在 global.asax 中将其替换为我的,并且所有视图都可以正确解析,除非我在每个视图中单独指定它,否则不会应用任何布局页面。
我的引擎路径格式代码是:
this.ViewLocationFormats = new[]
{
"~/UI/Views/{1}/{0}.cshtml",
"~/UI/Views/Shared/{0}.cshtml"
};
this.PartialViewLocationFormats = new[]
{
"~/UI/Views/Shared/{0}.cshtml",
"~/UI/Views/Shared/Partial/{0}.cshtml",
"~/UI/Views/{1}/Partial/{0}.cshtml"
};
this.AreaMasterLocationFormats = new[]
{
"~/UI/Views/Admin/Shared/{0}.cshtml"
};
this.AreaPartialViewLocationFormats = new[]
{
"~/UI/Views/Admin/Shared/{0}.cshtml",
"~/UI/Views/Admin/Shared/Partial/{0}.cshtml"
};
this.AreaViewLocationFormats = new[] { "~/UI/Views/Admin/{1}/{0}.cshtml" };
this.MasterLocationFormats = new[]
{
"~/UI/Views/{1}/{0}.cshtml",
"~/UI/Views/Shared/{0}.cshtml"
};
提前致谢, 斯科特
【问题讨论】:
-
这些视图是否在它们自己的区域内?
-
有基本视图,然后我设置了一个我注册的示例管理区域。我试着把这个区域拿出来看看它是否能解决它,但似乎没有。 _ViewStart.cshtml 不适用于任何视图。
-
当然,结果只是一个明显的疏忽……哎呀!我已经为我的问题提供了以下答案。
-
@Scott,我面临同样的问题,以下接受的答案对我没有帮助。有什么想法吗?
标签: asp.net asp.net-mvc viewengine