This paper is to consolidate the foundation
To facilitate understanding of the MVC framework, we first create an empty ASP. NET MVC Template
Here is the project structure after creation
The role of each file or folder
App_Data Application Data---as the name implies is the folder where files or databases are placed
App_start Application Startup folder
Filterconfig Global Filter Configuration---Determine user login and permissions, Action, tamper, and so on.
Routeconfig Routing Configuration
Webapiconfig WEBAPI Configuration
Public Static classWebapiconfig { Public Static voidRegister (httpconfiguration config) {config. Routes.maphttproute (Name:"Defaultapi", Routetemplate:"Api/{controller}/{id}", defaults:New{id =routeparameter.optional}); } }
Registering a default route
Controllers, Models, views controller, model, view folder
Global file: Global.asax is a text file that provides globally available code. The code includes the application's event handlers, as well as session events, methods, and static variables. Sometimes the file is also called an application file.
Public class MvcApplication:System.Web.HttpApplication { protectedvoid Application_Start () { Arearegistration.registerallareas ( ); Webapiconfig.register (globalconfiguration.configuration); Filterconfig.registerglobalfilters (globalfilters.filters); Routeconfig.registerroutes (routetable.routes); } }
New empty template Global file contains program-initiated methods
Packages.config package configuration, which marks the class library used in the project
The entire execution process
(Client) HTTP Request ---(Server App) Routing----- ViewResult --viewengine --andView -Response
The Web. config file places the globally configured XML file
ASP. NET MVC Learning path-2