Implementation of Master Page in MVC
using Razor
In asp.net
we all are familiar with Master page. Master page is used to create a common
layout for the web based application.
In Master
page we use Content Place Holder where we want to place other pages content.
Similarly we
use the concept of Master page in MVC. We create a View which will be common to
every page. Here we use @RenderBody() method instead of Content Place Holder.
For example:-
First of all
add MVC application using Visual Studio->File->Project->MVC 4
Now go to
view folder and add folder in which you can add your view which will work like
master page.
Figure 1
Now right
click to this folder and add view and give it a proper name. Now create your
complete Master page. And the place which you want to leave for other pages
content, add method @RenderBody().