我有一个遵循以下结构的 ASP .NET MVC3(剃刀)站点:
Site1
-Areas
-Area1
-Views
-SomeFeature
-Index.cshtml --> sets the section 'pageScripts'
-Shared
-_Layout.cshtml --> has Layout = ~/Views/Shared_Layout.cshtml, sets the section 'layoutScripts'
-Viewstart.cshtml ---> has Layout = ~/Areas/Area1/Views/Shared/_Layout.cshtml
-Area2
-Views
-Shared
-Views
-Shared
-_Layout.cshtml ---> has optional sections pageScripts, layoutScripts
这是我的问题:
当我尝试访问 的等效控制器方法时~/Area1/SomeFeature/Index
,我收到一条异常消息说
The following sections have been defined but have not been rendered for the layout page "~/Areas/Area1/Views/Shared/_Layout.cshtml": "pageScripts".
我将“pageScripts”部分定义为
@RenderSection("pageScripts", false) in ~/Views/Shared_Layout.cshtml
为什么我要这样做:
目前,我发现自己必须将 Area1(和 Area2)中每个视图中的 Layout 属性设置为~/Views/Shared/_Layout.cshtml
有谁知道我做错了什么?
- 感谢您的任何建议