ASP.NET MVC RenderSection

This post is as much for my own use as others as I’m always¬†forgetting how to add sections to an asp.net mvc masterpage.

In the master page add your subsection using:

<footer>@RenderSection(“Footer”)</footer>

and in the views implement this section using:

@section Footer {
<p>This is my footer</p>
}

You can make the section optional in your view:

<footer>@RenderSection(“Footer”, required: false)</footer>

This entry was posted in asp.net mvc. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *