@RenderBody (): Renders the principal content of a child page
@RenderSection (): Renders a special section section.
Helperresult rendersection (string name, bool required = TRUE);
Required default is true must overwrite, set to false is optional overwrite;
Note that the function in the RC version of the parameters have changed, the parameters of optional changed to required, it is said that the keyword conflicts with VB
Then I overwrite it in the footer section of the child page, and when the child page is implemented, use @section to customize the section name {} format.
If we want to write a default implementation section in the parent page, what do we do with the sub-page as an optional implementation?
This is directly supported in the MasterPage, but in the razor will be slightly more complicated, the personal feel that this writing can also be improved;
As shown, I wrote a default footer implementation on the parent page, and if the child page has an implementation then use the child page implementation, not the default implementation.
This is done by using the bool Issectiondefined (string name) function to determine if there is a child page implementation, and then the child page is called.
[email protected] () and @rendersection ()