----------------------------------------------------------
Note: The routing system does not have any expertise in controller and action. It simply extracts the values of the fragment variables and passes them along the request pipeline. In the request processing pipeline, the
Later, when the request arrives at the MVC framework, its value is assigned to the Controller and action variables.
Note: By default, the routing system examines whether a URL matches a disk file before evaluating the routing of the App.
When: Routes. Routeexistingfiles=true; Also routes existing files, modifying the default behavior.
Note: Controller and
----------------------------------------------------------
Knowledge Points:
1. TheMvcroutehandler class is a class of ASP. NET MVC application custom routing. (New Mvcroutehandler ()).
2.MapRoute Method: dedicated to MVC applications.
3.Mappageroute Method: For the ASP. NET Web form application.
4.HttpRequestBase, httpContextbase, httpResponsebase support for the MVC architecture of the routing system.
----------------------------------------------------------
First, the routing system two functions:
1. Examine an input URL and infer which controller and action the request wants.
2. Generate the output URL. These URLs are URLs that appear in the HTML rendered by the view so that when the user clicks on the link, the specific action is called.
Two key behaviors of URL mode:
1. Conservative : matches only URLs that have the same fragment as the pattern. (Note: The default value causes the URL of the number of 〈= fragments to match the pattern)
2. Loose : This mode is used to extract values for fragment variables as long as the correct number of fragments is available. (Note: Routing order)
Iii. default values, static URL fragments, custom fragment variables, constrained routing, routing of requests to disk files
1. Default value: The default value is used when the URL does not contain a value that matches a fragment. Provided as an attribute of the anonymous type.
This route will match 0 URLs (using 2 default values Home,index), 1 (using 1 default Index), 2 fragments
Routes. MapRoute (
" Myroute " , " {controller}/{action} " , New {controller= "Home", action="Index"} //provides a home default for the controller variable and provides an index default value for the action variable. );
2. Use a static URL fragment: Creates a pattern with a static fragment that is only a fragment in the URL, regardless of the controller or action. When requested, the Mvcroutehandler instance is matched with a variable in the URL parameter. when there is no {controller} or {action} in the URL parameter variable, the value must be assigned in the default value anonymous class.
3. Custom Fragment variables:
13th URL Routing