_Layout.cshtml is equivalent to Master Page in ASP.Net. Layout views provide the advantage of maintaining the consistent look and feel across all the views in an MVC application. We can place all repetitive code and reference files which are referred by the application commonly. For example below two files are required in our application in each view. If we will put these in _Layout.cshtml no need to refer in every view.
We can place a header bar, footer bar, navigation menu which are common to the application. It is good practice to put all common codes related to view in Layout file.
@Styles.Render("~/Content/css")@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")@Scripts.Render("~/bundles/bootstrap")@RenderSection("scripts", required: false)
@Scripts.Render("~/bundles/jquery")@Scripts.Render("~/bundles/bootstrap")@RenderSection("scripts", required: false)
We can place a header bar, footer bar, navigation menu which are common to the application. It is good practice to put all common codes related to view in Layout file.
No comments:
Post a Comment