Vs: how to create and understand MVC, vs how to create mvc

Source: Internet
Author: User

Vs: how to create and understand MVC, vs how to create mvc
How to create an MVC Project

1. Click "File Creation", "Project Creation", and "template.. NET Framework 4.0 or later). Select MVC 3 Web application or MVC 4 Web application. Modify the file name and location and click OK.

2. Select an empty view engine as much as possible, select ASPX, and click OK.

MVC project created

 

How to Understand MVC

After the project is created, the following files and folders are generated in Solution Explorer:

Controllers: Control Layer

Models: Data Layer

Views: view layer

 

The relationship between them is: the user is facing the control layer, there are various methods in the control layer for logical operations, if you need a view, adjust the template in Views to the Controllers control layer; if you want to query data in the database, set the data in Models to Controllers. The specific mode is as follows:

 

How to create and write MVC code

Write code in MVC mode, which is mainly written in the Controllers control layer. It interacts directly with the user: Right-click the Controllers folder and add a name (if the home page is used, try to use home ), however, do not change the following Controllers. Click Add.

How to add the Models data layer: Right-click the Models folder and choose add new item & #95; LINQ to SQL Class & #95; connect to the database and add data.

 

How to add the Views view layer: On the Controllers. cs page, right-click the code block where the mouse is located and add the view. The view engine selects ASPX (c.

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.