Page layout
Layout support is provided in ASP., by default the layout file is saved to the _layout.cshtml,view directory in the/view/shared/directory with a _viewstart.cshtml file, the code inside
@{"~/views/shared/_layout.cshtml";}
Indicates who is the default layout file under this directory. You can add this code to a specific view file to modify the boilerplate template page.
You can create a _viewstart.cshtml file into a subdirectory that sets the default master page for all views in this directory.
In this layout file, the contents of the content page are embedded by @RenderBody () code.
Section (region) is also supported on this page, and the area content defined in the view is embedded in the template page by @RenderSection ("Scripts", Required:false) .
You can specify whether the area in the view must be defined, and the view defines a region by the following code
@section the contents of the zone name {region}
Partial view
The features of the partial view are available in ASP. NET MVC, which allows you to get the contents of a partial view and embed it in the current page in the following way.
@{html.renderpartial ("view name", parameter );}
@Html. Partial (" view name "
@{html.renderaction ("ActionName", "Controllername", "Passing Parameters"); For example: @{html.renderaction ("Test", "Home", new {S=item}),//s is the parameter name of the action
@Html. Action ("actionname","controllername", " Pass parameters ")
Where action means to invoke the code inside the other action, passing the required data through the parameters, and embedding the contents of the detail view into the page via the return Partialview ().
Where partial means to embed the contents of another detail view directly into the page and pass the data required by the detail view through the parameters.
With the method of the start of the render, the contents of the detail view are written to the current view's response stream, which is a little more efficient. However, you must use code block mode @{code} calls.
A method that does not begin with a render, returns a string value that is embedded in the page.
ASP. NET MVC 4 Advanced Programming Learning Notes: Chapter III view (2)