The following table lists the differences between the RenderBody() and RenderSection() methods.
|The RenderBody() method must be present in the layout view.||The RenderSection() method is optional.|
|RenderBody() renders all the content of the child view which is not wrapped in the named section.||RenderSection() renders only a part of the child view which is wrapped under the named section.|
|Multiple RenderBody() methods are NOT allowed in a single layout view.||Multiple RenderSection() methods are allowed in a single layout view.|
|The RenderBody() method does not include any parameter.||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.|
Visit Layout View chapter for more information.
- Difference between Html.Partial() and Html.RenderPartial() in ASP.NET MVC
- How to pre-compile razor view in ASP.NET MVC?
- How to enable bundling and minification in ASP.NET MVC?
- How to enable client side validation in ASP.NET MVC?
- How to display an error message using ValidationSummary in ASP.NET MVC?
- How to bind a model to a partial view in ASP.NET MVC?
- View in ASP.NET MVC