---
title: "What is difference between RenderBody and RenderSection in ASP.NET MVC"  
description: "What is difference between RenderBody and RenderSection in ASP.NET MVC"  
author: "Sachin Singh"  
published: 2016-03-25  
updated: 2016-03-25  
canonical: https://www.mindstick.com/forum/34075/what-is-difference-between-renderbody-and-rendersection-in-asp-dot-net-mvc  
category: "asp.net mvc"  
tags: ["c#", "asp.net", "asp.net mvc"]  
reading_time: 2 minutes  

---

# What is difference between RenderBody and RenderSection in ASP.NET MVC

Hi All,\
In [ASP.NET MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) [Razor syntax](https://www.mindstick.com/forum/160235/what-is-razor-syntax-and-how-does-it-help-in-embedding-server-side-code-within-a-view), we will unable to understand the use of **@RenderBody.** My [layout page](https://www.mindstick.com/forum/649/set-header-and-footer-with-in-master-page) is below:\
![What is difference between RenderBody and RenderSection in ASP.NET MVC](https://www.mindstick.com/mindstickforums/89effd5b-4325-4a5e-891d-6c1ff05381c2/images/76f2e15d-405b-4b2a-a4ff-0a03564dc722.png)\
Can anyone give me a proper explanation of these two.\
Thank you.

## Replies

### Reply by Anupam Mishra

Hi Sachin,\
A **RenderSection** allow to specify a region of content within a [layout](https://www.mindstick.com/articles/12853/android-layout-and-its-type). It expects one parameter which is the name of the section. If we do not provide that, an exception will be thrown. A section in a layout [page](https://www.mindstick.com/articles/13031/why-to-make-a-wikipedia-page) can be defined by using the following code.\

```
@section header{    <h1>Header Content</h1>}
```

we can render above defined section header on the content page as given below:\

```
@RenderSection("header")
```

By default, sections are mandatory. To make sections optional, just provides the second parameter value as false, which is a Boolean value.\

```
@RenderSection("header",false)
```

A view can define only those sections that are referred to in the layout page otherwise an exception will be thrown.\
**RenderBody:** **RenderBody** method exists in the Layout page to render child page/view. It is just like the **ContentPlaceHolder** in master page. A layout page can have only one **RenderBody** method.\

```
@RenderBody()
```

For more details. [CLICK HERE](https://www.mindstick.com/blog/739/layouts-renderbody-rendersection-and-renderpage-in-asp-dot-net-mvc-4)


---

Original Source: https://www.mindstick.com/forum/34075/what-is-difference-between-renderbody-and-rendersection-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
