MVC, layout page, mvc layout page
I."
In the _ ViewStart. cshtml file, add:
@ {Layout = "~ /Views/Shared/_ Layout. cshtml "; PageData [" aaa "] =" I'm wow, haha ";}
Create an Action method, add the corresponding view (use the layout page), and add
@{ ViewBag.Title = "ViewStart";}
Then run the view page:
II.
Add the following code to the Layout page _ Layout. cshtml file:
<!DOCTYPE html>
Then, add the following code in the ViewStart. cshtml file on the view page of the layout page:
@ {ViewBag. title = "ViewStart" ;}< h2> ViewStart
Then run the page:
View source files:
<! DOCTYPE html> Conclusion: The RenderSection is a small pitfall. It can be used to dig many small pitfall and use the layout pages.
@ RenderBody () is a big pitfall, that is, the layout page. You can write a lot of content on your own page, which is put in the @ RenderBody () method, if there is a small pitfall, the corresponding content will also be put in!