First, Routing
The correspondence between the "URL path" and "Document path" for ASP. NET MVC is defined by "URL routing (Routing)", and we can see a registerroutes method from the App_start\routeconfig.cs document within the project:
public static void RegisterRoutes (RouteCollection routes)
{
Route. Ignoreroute ("{resource}.axd/{*pathinfo}");
Route. MapRoute (
Name: "Default",
URL: "{controller}/{action}/{id}",
Defaults:new{controller= "Home", action= "Index", id=urlparameter.optional}
);
}
In the RegisterRoutes method:
Ignoreroute the URL path for setting. Axd format does not run through ASP.
The Maproute method is the most important way to define ASP. URL Routing: name--route name, url--setting URL path to controller, action and route value, defaults--setting {controller}, {action}, {ID} The default values for these 3 route parameters.
Ii. ASP. NET MVC life cycle
The three main processes of the ASP. NET MVC life cycle are:
1. URL routing alignment;
By default, if the requested URL corresponds to an entity document relative to the root of the Web site, it will not be processed through ASP. NET MVC, but will be automatically skipped over all URL routing pairs and delivered directly to IIS or ASP. If you want to change this behavior, you can global.asax in the Application_Start () The RouteTable.Routes.RouteExistingFiles is set to true at the front of the event so that the UrlRoutingModule module does not first determine if there is an entity document, but rather a comparison of the URL routing rules defined by the registerroutes, if Will enter the MVC runtime, and will fail to return the run right to IIS.
2. Run the Controller and action;
3. Run the view and return the results.
Routing and ASP. NET MVC life cycle