---
title: "Creating Master page in MVC"  
description: "Master page or Layout is a common layout for all the pages in the web application. Suppose we want common look and feel for many pages like headerfoot"  
author: "Manish Kumar"  
published: 2017-02-22  
updated: 2018-03-17  
canonical: https://www.mindstick.com/blog/11302/creating-master-page-in-mvc  
category: "asp.net"  
tags: ["asp.net mvc", "mvc"]  
reading_time: 2 minutes  

---

# Creating Master page in MVC

Master page or [Layout](https://www.mindstick.com/articles/12853/android-layout-and-its-type) is a [common](https://www.mindstick.com/articles/23170/10-most-common-accounting-mistakes-of-small-business) layout for all the pages in the [web application](https://www.mindstick.com/articles/13069/progressive-web-application-pwas-all-you-need-to-know-about). Suppose we want common look and feel for many pages like **[header](https://www.mindstick.com/articles/336036/explain-about-html-header-body-and-footer-tags), footer, logo** for this we make layout in the shared folder and shared folder should be in the View folder.\

**Step for adding layout in the application**

Create new [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects)

Add a new folder in the view

Right click in the shared folder go to add then click new item

![Creating Master page in MVC](https://www.mindstick.com/blogs/1a978f2a-2857-46f1-9b4a-02886422e57c/images/247a60d6-43fa-4c85-ba8d-fe55f415c517.png)\

## Select MVC Layout Page

![Creating Master page in MVC](https://www.mindstick.com/blogs/1a978f2a-2857-46f1-9b4a-02886422e57c/images/af835770-b912-4dd0-bb0d-6714876f8501.png)\

**When we click this will come [default](https://www.mindstick.com/interview/12771/what-is-the-importance-of-default-resources)**

```
<!DOCTYPE html> <html><head>    <meta name="viewport" content="width=device-width" />    <title>@ViewBag.Title</title></head><body>    <div>        @RenderBody()    </div></body></html> 
```

\

@RenderBody() is used only once in in the layout and @[RenderSection](https://www.mindstick.com/blog/739/layouts-renderbody-rendersection-and-renderpage-in-asp-dot-net-mvc-4) is can be used [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) time

**For common look I have used some code in layout**

```
<!DOCTYPE html> <html><head>    <meta name="viewport" content="width=device-width" />    <title>@ViewBag.Title</title>    <link href="~/Content/bootstrap.min.css" rel="stylesheet" />    <script src="~/Scripts/jquery-3.1.1.min.js"></script>    <script src="~/Scripts/bootstrap.min.js"></script></head><body>    <div class="container">        <section class="box">     <nav class="navbar navbar-inverse">  <div class="container-fluid">    <div class="navbar-header">      <a class="navbar-brand" href="#">Mindstick</a>    </div>    <ul class="nav navbar-nav">      <li class="active"><a href="#">Home</a></li>      <li class="dropdown">        <a class="dropdown-toggle" data-toggle="dropdown" href="#">Page 1        <span class="caret"></span></a>        <ul class="dropdown-menu">          <li><a href="#">Page 1-1</a></li>          <li><a href="#">Page 1-2</a></li>          <li><a href="#">Page 1-3</a></li>        </ul>      </li>      <li><a href="#">Page 2</a></li>      <li><a href="#">Page 3</a></li>    </ul>  </div></nav>    <div>       @RenderBody();    </div>        <div class="panel-footer"> Footer</div>            </section>      </div> </body></html> 
```

\

**Using layout in the view**

Add [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) and add action in the view

```
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc; namespace
MvcApplication6.Controllers{         public class HomeController : Controller    {        //        // GET: /Home/         public ActionResult Index()        {            return View();                  }      }} 
```

**Then add index view and call master page or layout like this**

```
@{    Layout ="~/Views/shared/_LayoutPage.cshtml";} <h1>Hello</h1> 
```

## \

**Output**\

***\***

![Creating Master page in MVC](https://www.mindstick.com/blogs/1a978f2a-2857-46f1-9b4a-02886422e57c/images/8975f029-47ae-4fb8-a94b-9474755c1bce.png)\

***\***

**You can also visit this useful post**

[Master Page in C# Window forms](https://www.mindstick.com/Articles/1450/master-page-in-c-sharp-window-forms-part-ii)

---

Original Source: https://www.mindstick.com/blog/11302/creating-master-page-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
