Asp.net mvc 3 如何:区域中的嵌套布局?
我有一个ASP.NET MVC3(razor)网站,其结构如下:Asp.net mvc 3 如何:区域中的嵌套布局?,asp.net-mvc-3,asp.net-mvc-areas,Asp.net Mvc 3,Asp.net Mvc Areas,我有一个ASP.NET MVC3(razor)网站,其结构如下: Site1 -Areas -Area1 -Views -SomeFeature -Index.cshtml --> sets the section 'pageScripts' -Shared -_Layout.cshtml -->
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".
我将“页面脚本”部分定义为
@RenderSection("pageScripts", false) in ~/Views/Shared_Layout.cshtml
我为什么要这么做:
目前,我发现自己必须将区域1(和区域2)中每个视图的布局属性设置为~/Views/Shared/\u Layout.cshtml
有人知道我做错了什么吗
-谢谢你的任何建议只是瞎猜 1.)确保使用的是_ViewStart,需要下划线;) 2.)确保_ViewStart位于区域的Views文件夹中,而不是区域1文件夹中。至少在你的描述中是这样的 希望这些建议中的一个能起到作用。我使用类似的技术,效果很好 干杯 涡流