RenderBody() and RenderPage() in MVC.

RenderBody()



If you are aware about Web Forms then RenderBody() method is like ContentPlaceHolder in Web Forms.
This exists in Layout page and it will render the child View/Page. RenderBody() renders the content of the child which is not wrapped in the section.
The RenderBody() method must be present in the Layout view and Layout page will have only one RenderBody() method.And we can't pass any parameter to RenderBody() method.

@RenderBody()


RenderPage()


RenderPage() method also exist in Layout Page to render the other pages exists in the same application. multiple RenderPage() can be there in layout page.

@RenderPage("~/Views/Shared/_Notification.cshtml";)

I hope this clears up the basic differences between RenderBody() and RenderPage() in MVC.

Comments

Popular posts from this blog

Difference Between return View(), return Redirect(), return RedirectToAction() And RedirectToRoute() In MVC.

Basic Difference Between Convert.ToString() And .ToString() Method In C#