1. Definition
Model-View-Controller (MVC) is used to represent a software architecture Model. It divides software systems into three basic parts: models, views, and controllers.
2. Differences between MVC and WebForm Modes
- WebForm Mode
A URL request is a physical file in the corresponding path of the server and the URL. The file then processes the request and returns the result to the client.
- MVC Mode
The requested URL of the client is mapped to the corresponding Controller. Then, the Controller processes the business logic and may retrieve data from the Model, then, the Controller selects the appropriate View and returns it to the client.
3. directory structure of ASP. net mvc Project
- App_Data: used to store data
- Content: used to store resource files (CSS, JS, images, etc)
- Controllers: used to store the Controller class. The name of the Controller class must end with Controller.
- Models: class used to store business entities and data access layer code
- Views: stores view files. Each Controller corresponds to a view folder.
The Shared sub-directories under the Views directory are used to store Shared Views. For example, Error. aspx and Site. Master
4. ASP. net mvc core DLL
- System. Web. Routing: URL Routing. Route a URL to the corresponding Controller. It is processed in HttpModule.
- System. Web. Extensions: ASP. NET AJAX
- System. Web. Mvc: the main assembly of ASP. net mvc.
- System. Web. Category actions: some related base classes. For example, HttpContextBase and HttpRequestBase.
5. Routing
- Add routes to the Application_Start event in the Global. asax file. This ensures that routes is available when the program starts and allows you to call this method directly during unit testing. If you want to call this method directly during unit testing, the method for registering the routes must be static and have a RouteCollection parameter.
Public static void RegisterRoutes (RouteCollection routes) {// ignore the pair. the Route of the axd file, that is, directly accessing the file like WebForm. axd file routes. ignoreRoute ("{resource }. axd/{* pathInfo} "); routes. mapRoute ("Category", // Route name "Category/{action}/{categoryName}", // URL with parameters new {controller = "Category ", action = "Index", categoryName = "4mvc"} // set the default parameter);} protected void Application_Start () {// register the previously defined Route rule RegisterRoutes (RouteTable. routes );}
6. Controller and Action
7. View and ViewData
8. TempData
9. Submit and bind Helper with data
10. ModelState and data verification
Http://www.cnblogs.com/fish-li/archive/2012/02/12/2348395.html
From: http://www.cnblogs.com/QLeelulu/archive/2008/09/30/1302462.html #
Reference: http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-1