MVC 3 - Nested layouts - sections don't render in Areas

后端 未结 2 2179
暗喜
暗喜 2021-02-20 07:45

Problem:

Given this nested layout structure:

~/Views/Shared/_layoutBase.cshtml
~/Views/Shared/_layout.cshtml

Where _layoutBase.cshtml i

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-20 08:28

    The Reason Why:

    I have got up this morning and saw the problem straight away:

    I had the @section blocks in a Partial View. In MVC 3, that WON'T work!!

    ARGH!

    I really appreciate Darin's effort, that effectively provided proof that sections do work in Areas as expected. But the real cause was this.

    I forgot they were in a Partial View, because I have a mvc 3 wizard that uses partial views for steps. It works so well and consistently, using ajax if javascript is available, that you forget what you are doing.

    Please give Darin a vote, but this is the real answer.

提交回复
热议问题