The RenderSection Razor trick seems kind of hacky. Per this one would do a declaration like this in _Layout.cshtml (the master page):
@RenderSection("SideBar", required: false)
You may then write contents for the Section anywhere in a view using the master page:
@section SideBar {
<p>foo</p>
}
Where the section will end up rendering in the HTML will be driven by where the section is defined in the master page and not the inheriting view!
No comments:
Post a Comment