The blog has moved to http://jessehouse.com/ ... Many google searches point here so I am leaving it operational, but there will be no new posts.

Wednesday, November 17, 2010

ASP MVC Razor templates with nested layout and sections

Using ASP MVC 3 with Razor views.

Ran into an issue with nested layouts and wanting to render a section in a top level layout, but define it in the view which uses a 'child' layout (master) page. This was generating a runtime error of:

The following sections have been defined but have not been rendered for the layout page... 

I posted some code to the asp.net forum and github. A nice workaround was supplied by 'Imran Baloch'


1 comment:

billy.braga said...

I had the same problem. Seems when you have three levels of layouts, the intermediate one must render all sections of the child, even if the top most parent will do so.