The previous article has WebForm and html+ashx way development, the following emphasis says MVC creates
VS in New Web project, next select MVC, the project can be built directly to run the test structure
Main Model Folder View folder Controller folder
Content folder put CSS file, scripts folder to put JS file cshtml
The view template file, which will eventually be View+controller to a pure HTML file, corresponds to a folder in the view with several cshtml files in each module of the Web site. and each module name in the Model folder has the module name +controller controller file corresponding, the controller file has several methods and view of the cshtml respectively corresponding. When the URL suffix access to/module name, enter the appropriate controller, when access to/module name/cshtml file name, enter the corresponding method in the controller, in the method will do some data operation after return view () returned to the Web page after the cshtml file. do some data manipulation
The above bold to do some data operation specific implementation:
By passing in the model parameter in the controller, you can directly use the data defined in model, after obtaining the data, you can do the middle operation like assigning to the page template. Model
The model can do some database operations, such as using an ORM (Object Relational Mapping) framework, or using the Dbhelp file to manipulate the database itself, and define the parameters, Get/set, and so on.
in general, the class name corresponds to the table name, the property corresponds to the field The example uses ORM framework, constructs a class name corresponding table name, the attribute corresponding field model constructs a table module, inside has the increment to check four cshtml files, each file writes corresponding Template table's controller, inside has the enhancement check corresponding method, Reference to model, ID in each method to write a good corresponding operation
www.xxx.com/table/Check
The table will be displayed
www.xxx.com/table/Change
The edit page will be displayed
The appropriate method to access the table controller when the operation enters the page