MVC, layout page, mvc layout page

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.