MVC master Page _layout.cshtml

Source: Internet
Author: User

Remember that at the time of ASP, we often use master page masterpage. MVC also has this feature, which is more convenient to apply than masterpage.

Before this exercise, all of the MVC exercises were to create separate pages. Insus.net would like to take the example of previous exercises and move to the master page. In the case of ASP, if you want to put a single page that has already been written into the MasterPage master page, with insus.net experience, you have to recreate it and then copy the relevant content to the new page. Now MVC, moving a page that already exists to the master page, is fairly easy, with one or two lines of code.

MVC creates a site master page, where you can add a shared directory to the views directory first. This can be the master page _layout.cshtml created here.



Insert the knowledge point, in the #17 line code, in order to output an "@" character, just put one more "@" on the line.

Change the existing page, just modify the following sentence Layout = "~/views/shared/_layout.cshtml"; Such as



Detailed real-time operation process:

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.