One, the structure such as
Two, layout page and view layout page
1 "How to use one
_viewstart.cshtml
@{ "~/views/shared/_layout.cshtml";}
_layout.cshtml
<! DOCTYPE html>"viewport " content=" width=device-width" /> <title> @ViewBag .title</title> @RenderBody () </ Div></body>
Comprehensive:
1 When you use this notation: If the View layout page _viewstart.cshtml does not exist or layout = "~/views/shared/_layout.cshtml", the page fault that points to will cause the layout page of the view (_ layout.cshtml) use failed
2 "But the View layout page _viewstart.cshtml its own style, and so on the same global, and does not expire
2 Using method Two (do not use the View layout page _viewstart.cshtml)
_layoutnew.cshtml
<! DOCTYPE html>"Viewport"Content="Width=device-width"/> <title> @ViewBag .title</title>@RenderSection ("Head",false)Layout page _layoutnew.cshtml@RenderSection ("Main",false) </div></body>hz.cshtml using templates
@{ "~/views/shared/_layoutnew.cshtml";} @section head{} @section main{ Hz page using _layoutnew.cshtml templates }
That is, the application of the template is as successful as this, it is important to note that @section head{} @section main{} name needs to be defined as the layout page
Third, the use of partial pages (do not need to create an action, simple to use)
Index.cshtml
@Html. Partial ("_partialview")
You do not need to use the controller (Controllers) and method (action) to directly use the elements of this page
Layout pages for MVC, view layout pages, and distribution page usage