asp.net - RenderBody() and RenderSection() must be on every child layout? -


i have 3 simple layout,

_layout.cshtml (this base layout)

@rendersection("something", required: false) @renderbody() 

_main.cshtml

@{     layout = "~/views/shared/_layout.cshtml"; } @section {    hey i'm on _main layout. } 

index.cshtml

@{     layout = "~/views/shared/_main.cshtml"; } 

when try render index view in action, got error,

the "renderbody" method has not been called layout page "~/views/shared/_main.cshtml".

but wait, _main.cshtml has parent layout has renderbody(). wrong, must call renderbody() every child layout?

yes, renderbody should included on every layout page, regardless nesting.

@renderbody works placeholder engine know drop content of view using layout page.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -