_layout Code:
1<! DOCTYPE html>234<meta charset="Utf-8"/>5<meta name="Viewport"Content="Width=device-width"/>6<title> @ViewBag .title</title>7@RenderSection ("Headarea", Required:false)89<body>Ten @RenderBody () One A@RenderSection ("Bodyarea", Required:false) - -</body> theUse the Sub-page code for the layout page:
1 @{2 //The layout property of this page has been assigned in _viewstart.cshtml! 3Viewbag.title ="Sonpage";4 }5 6<!--sub-pages where all unused @section places are in the corresponding layout @renderbody ()--78I love Guangzhou small waist ~~~~<br/>9I love bungee jumping ~ ~ ~! Ten One<!--corresponding to the layout @rendersection ("Bodyarea", Required:false), Required:false is not required- A @section headarea{ -I'm going to jump into a little hole, ~~~~~~~~~.! - What are you doing to me? the signed by: Fragrance Kids -}
All view pages use layout pages because each request executes the _viewstart.cshtml page, and the _viewstart.cshtml page assigns values to the layout properties of the page.
Many do not use the layout page will be emptied layout
1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<title>TransData</title> One A<body> -</body> -MVC Learning VI: "/views/shared/_layout.cshtml" of razor layout view