Introduction to ASP. net mvc and asp. netmvc
The full name of MVC is Model View Controller, short for model-view-controller. It is a Model of software design, organize Code by means of separation of business logic, data, and interface display, and integrate the business logic into a component to improve and personalize the custom interface and user interaction, you do not need to rewrite the business logic. MVC is uniquely developed to map traditional input, processing, and output functions in a logical graphical user interface structure.
MVC is one of three ASP. NET Programming modes.
Model (Model layer) indicates the application CORE (such as the database record list ).
View (View layer) displays data (database records ).
Controller (Controller/layer) processes input (written to database records ).
Create an MVC Program
Create a project
ASP. net mvc 4 Web Applications
Select template-control; view engine-ASPX
After you click OK, VS will automatically generate five folders and related configuration files. The names of these five folders cannot be changed, and corresponding sub-pages are placed in the corresponding folder, you do not need to specify the folder name when using it.
App_Data folder
App_DataFolder is used to store application data.
Controllers folder
The Controllers folder contains the Controller class responsible for processing user input and the corresponding.
MVC requires that the names of all Controller files end with "Controller.
Models folder
The Models folder contains classes that represent the application model. The model controls and operates application data.
Views folder
The Views folder is used to store HTML files (user interfaces) related to application display ).
The Views folder contains a folder corresponding to each controller.
Daily use of MVC:
1. MVC needs to be generated frequently
2. Data can be displayed on any page
3. Place LinQ in the model and reference the namespace for use.
4. You cannot use the WebForm control on the MVC View page.
5. Use reference data or C # code on the MVC View page, which must be placed in <% code %>. Reference of the namecontrol <% @ important Namespace = "" %>
Layer C
Consists of the actions in the Controller and controller.
The MVC request is not directly to the page, but to send a request to an action in the controller.
The Index action under the Home controller is returned by default.
If the requested controller does not have a request action, the Index action under the controller is returned by default.