Nested layouts for MVC5

前端 未结 2 1828
甜味超标
甜味超标 2021-02-05 10:27

I\'ve seen a few posts on this topic:

Razor Nested Layouts with Cascading Sections

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

And it alw

2条回答
  •  伪装坚强ぢ
    2021-02-05 11:14

    I know it's an old question. I thought I'd share this anyway in case anyone else runs into this (like I did).

    At the bottom of your child layout, you define a section with the same name as the section in the parent layout. Inside of this section you simply put a @RenderSection, again specifying the same name as before. Once this is in place, you essentially have the child layout "bypass" content from pages, up to its parent layout:

    @section breadcrumbs {
        @RenderSection("breadcrumbs", true)
    }
    

提交回复
热议问题