RenderSection in ASP.Net MVC

Last Reply 11 months ago By dharmendr

Posted 11 months ago

I have found a rendersection inside _layout.cshtml file

I even didnt figureout what it does exactly..??

@RenderSection("scripts", required: false)

can any body tells what it does exactly


Thanks ..

Posted 11 months ago

Hi Prasunjeet,

In layout pages, renders the content of a named section.

RenderSection renders only a part of the child view which is wrapped under the named section.

Multiple RenderSection() methods are allowed in a single layout view.

The RenderSection() method includes boolean parameter required, which makes the section optional or mandatory. If the required parameter is true, then the child view must contain the section.

Refer below link for more details.

RenderSection Method

RenderSection With Example