What is the principle of
asp.net is the address mapping principle through the HttpModule request to complete the work.
understand the principle, I completed a simple address mapping code is as follows:
borrow Bo pictures
< / / / /summary>
The definition of
public address rewrite
asp.net address mapping is the actual file mapping virtual address user access, virtual address may be static page. Such as: during a visit to the 贵族宝贝fuzhou.naoqiu贵族宝贝/bus page, in fact, visit the /bus.aspx page.
a HTTP request in the transfer process of HttpModule container, at a time (ResolveRequestCache event) will request the HTTP transfer to the HttpHandler container. In the aftermath of the incident, an instance of the HttpModule container entrance will set up an HttpHandler, but did not hand over control of the HTTP request, but continue to trigger the AcquireRequestState event and PreRequestHandlerExcute event. After PreRequestHandlerExcute, the HttpModule window will control to the HttpHandler container, so that the real HTTP request processing work.
first address mapping base class:
/ / / >
and HttpHandler in the inside of the container will execute the ProcessRequest method to handle the HTTP request. After the container HttpHandler dealt with the HTTP request, will control back to the HttpModule, HttpModule will continue to finish the HTTP request information flow to the layers of action, until the return to the client.
public abstract class BaseModuleRewriter: IHttpModule