ArticleDirectory
- 1. Basic Structure of the route module.
- 2. Find the appropriate route to parse the current URL
This article mainly describes the basic working principle of ASP. NET route components. The route component was originally a part of MVC, but was later independent.ProgramAs the route component is the basic component of ASP. NET, how does the route component forward the request to MVC when a request arrives? Yesterday I downloaded ASP. NET MVC2Source codeI was always cheated by maproute. this method is not a built-in method of the route component, but an extension method provided by the MVC module. in this extension method, it explicitly specifies routehandler as mvcroutehander. why is the extension method of MVC not called mapmvcroute? Return to the route component itself. In fact, the route component itself is a very simple module. It mainly provides the following two functions:
- Find the appropriate route to parse the URL of the current request.
- Find the appropriate route to generate the URL.
1. Basic Structure of the route module.
Shows the basic structure of the route module:
In the figure above, routetable, routecollection, routebase, routedata, and iroutehandler are the core components of the route module. route is a reference implementation of routebase. the style of Microsoft's work is to provide an abstract architecture while providing a good enough reference for implementation. if you need to expand the abstract architecture on a large scale, you must distinguish them. ihttphandler is ASP. NET platform basic interface.
2. Find the appropriate route to parse the current URL
To be continued...