I have learned that the web should know the master page of this thing, here, the MVC template page and the Web Template page is the same effect and purpose.
First: Create a project, controller, generate the index view, when generating the view we select the Razor view engine, and then tick the "Use Layout or master page" option, which defaults to the layout of the _layout.cshtml page referenced. The page has been configured in the _viewstart.cshtml file, and all Razor engine pages will execute this viewstart page before execution.
@{
Layout = "~/views/shared/_layout.cshtml";
}
The layout keyword is the code that points to the default page layout. This view is much cleaner than the ASPX view.
Custom Layout page:
<! DOCTYPE html>
<meta charset= "Utf-8"/>
<meta name= "viewport" content= "Width=device-width"/>
<title> @ViewBag .title</title>
@Styles. Render ("~/content/css")
@Scripts. Render ("~/bundles/modernizr")
<body>
<p>this is up</p>
@RenderBody ()
<p> this is down</p>
@Scripts. Render ("~/bundles/jquery")
@RenderSection ("Scripts", Required:false)
</body>
What is written in the Child View page is where the layout page @renderbody defined.
@RenderSection Layout page also has the concept of sections (section)
Of course, our display is still going to be written in the view.
---Index:
@{
Viewbag.title = "Index";
Layout = "~/views/shared/_layout.cshtml";
}
<p>this is layoutview</p>
MVC Template Page