RenderSection in ASP.Net MVC

Last Reply 23 days ago By dharmendr

Posted 23 days 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 23 days 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