What Is The Use Of Layout In MVC ? And Difference Between Layout And ViewStart In MVC

Posted by Kasani007 under ASP.NET MVC on 8/9/2014 | Points: 10 | Views : 5948 | Status : [Member] | Replies : 3
What Is The Use Of Layout In MVC ? And Difference Between Layout And ViewStart In MVC




Responses

Posted by: Bandi on: 8/11/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
A layout is used to provide a consistent look and feel of all pages of a web application so we create a layout for the web application.

http://www.codeproject.com/Articles/721055/ASP-NET-MVC-Layout-and-Section-in-Razor
http://stackoverflow.com/questions/5161380/how-do-i-specify-different-layouts-in-the-asp-net-mvc-3-razor-viewstart-file
http://www.dotnet-tricks.com/Tutorial/mvc/9Ya6290314-Layouts,-RenderBody,-RenderSection-and-RenderPage-in-ASP.NET-MVC.html


Layouts are like as Master Pages in Asp.Net Web Forms. These helps us to maintain consistent look and feel across all the views within your Asp.Net MVC application. Like Master Pages, Layout may contains common CSS, jQuery files across the multiple Views and one or more placeholders for which Views provide content.
In Asp.Net MVC, at application level we have _ViewStart file with in Views folder for defining the default Layout page for your Asp.Net MVC application.

http://www.dotnet-tricks.com/Tutorial/mvc/3WDE140613-Different-ways-of-rendering-layouts-in-Asp.Net-MVC.html

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabu_Spark on: 8/11/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Layout:
Layout is like a master page, it will give the same look and feel for your website.

ViewStart:
Viewstart is used to set the default layout page for the child pages.



With regards,
J.Prabu.
[Email:prbspark@gmail.com]

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Manimaddu on: 8/11/2014 [Member] Starter | Points: 25

Up
0
Down
Layouts that allow you to define a common site template, and then inherit its look and feel across all the views/pages on your web application.

The role of viewStart is to avoid to repeat some code that must be the same between views. For example, the layout for the view. Instead of defining the the top of each view what layout to use, you can simply define a layout at the root of your views folder a file _ViewStart.cshtml

Thanks & Regards,
Mani Kumar

Kasani007, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response