2012-08-03 52 views
0

我有以下這種結構的ASP .NET MVC3(剃刀)網站:Howto:嵌套佈局的區域?

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 

這裏是我的問題:

當我嘗試訪問equivalient控制方法~/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 

爲什麼我試圖做到這一點:

此刻,我發現自己不得不在區域1(區域2和)每個視圖佈局屬性設置爲~/Views/Shared/_Layout.cshtml

是否有一個知道我在做什麼錯了?

- 感謝您的任何建議

回答

0

只是在黑暗中的一槍。

1.)確保你正在使用_ViewStart,需要下劃線;)。

2.)確保_ViewStart位於Area中的Views文件夾中,而不在Area1文件夾中。至少在你的描述中看起來就是這樣。

希望其中的一個建議可以訣竅。我使用類似的技術,工作得很好。

乾杯,

埃迪