1. Back To Blog

Explain the difference between layout and master pages ? (MVC Razor interview questions)

Layout are like master pages in ASP.NET Web form. Master pages give a standard look and feel for Web form views while layout gives standard look and feel or acts like a template for razor views.


How to apply layout to Razor views?


So first we need to create a template file as shown in the below code.


<div>

@RenderSection("Header")

@RenderBody()

@RenderSection("Footer")

</div>


And then apply this template to the view as shown below and display data in those respective sections.


@Layout = "/Views/Default1/_LayoutPage1.cshtml";}

This is body

@section  FooterCopyright 2015-2016}

@section HeaderWelcome to my site}


You can go through these 100 MVC interview question with answers from

http://www.codeproject.com/Articles/556995/MVC-interview-questions-with-answers


In case you are new to MVC you can start from the below MVC step by step video


Shiv Prasad Koirala

Visit us @ www.questpond.com or call us at 022-66752917... read more

We are on Social