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.