1
Answer

RenderBody()

Photo of David Smith

David Smith

11y
3.1k
1
MVC 4


Can someone explain what RenderBody() does in detail. I am new to MVC.

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/myCss.css")" rel="stylesheet" />
</head>
<body>
    <div>
        @RenderBody()
    </div>
</body>
</html>

Answers (1)

0
Photo of Sunny  Sharma
NA 18.4k 1m 11y
Hi David,

@RenderBody() is a helper method in ASP.NET MVC and is very similar to <asp:ContentPlaceholder> tag in ASP.NET master pages.
@RenderBody() renders portion of a content page which that is not within a named section. ASP.NET MVC also provides @RenderPage() & @RenderSection() helper methods to render content of a page in other page and render the content of a named section respectively.

I suggest you to visit here: http://www.w3schools.com/aspnet/mvc_htmlhelpers.asp

This will give you more insight on the topic.

Hope it helps :)