This ensures that during the Execute Handler stage, IIS will execute the handler that was selected by the routing module. If it does, ASP.NET routing uses the information to set the Handler property of the current HTTP context. If no route is found, the module does not do anything, and the URL falls through and is processed normally (typically by matching it to a file on disk).ĭuring the PostMapRequestHandler event, the module checks if the HTTP context contains any information about a handler. NET Framework object that implements the interface. If a match is found, the module obtains a reference to the handler that corresponds to that route and saves the reference as part of the current HTTP context. ASP.NET routing is configured to run for all requests made to the Web application.ĭuring the PostResolveRequestCache event, the module looks through a routing table (a collection of route objects) for a route that matches the requested URL path. In terms of IIS and ASP.NET architecture, this process is represented by the following diagram:ĪSP.NET routing is implemented as a managed-code module that plugs into the IIS request-processing pipeline at the Resolve Cache stage (PostResolveRequestCache event) and at the Map Handler stage (PostMapRequestHandler event). If the route is found, the corresponding handler for that route is invoked to process that request. When a request is made to a Web server ASP.NET routing looks up the requested URL path in the list of registered routes. This association is done by registering the "routes" that define which handler to invoke for a particular URL path. ASP.NET RoutingĪSP.NET routing is a request-dispatching mechanism that lets developers associate a certain URL with a handler that can process requests made to that URL. This means that the handler selection in the IIS pipeline is made based on the rewritten URL that is produced by the URL Rewrite module. After all the rules have been evaluated, the URL Rewrite module produces a final URL path that is used for the request through the remainder of the IIS pipeline processing. Each rewrite rule analyzes the URL path and, if all the rule conditions are met, changes the original path to a new path. The URL Rewrite module is a native code module that plugs into the request-processing pipeline at the Pre-begin Request or Begin Request stages, and then evaluates the requested URL path by using a set of rewrite rules. In terms of the IIS architecture, this process is represented by the following diagram: The requesting client never sees the rewritten URL as far as the client is concerned, it has received a response from the original URL. The handler, which is chosen based on the rewritten URL, processes the request and generates a response that is sent back to the Web browser. The URL rewriting module runs early in the request-processing pipeline, modifying the requested URL before the Web server decides which handler to use to process the request. When a client sends a request to the Web server for a particular URL, the URL rewriting module analyzes the requested URL and changes it to a different URL on the same server. Many popular applications that are hosted on Apache now rely on URL rewriting to enable support for "clean" URLs. Since then it has proven to be a very useful tool for Web server administrators and Web developers. It was introduced in the Apache Web server about a decade ago. The basic idea of URL rewriting is not a new concept. To help you understand those differences, we will first explain how IIS URL rewriting and ASP.NET routing work. However, there are fundamental differences between these two technologies that are important to understand to make the right decision about what to use for your Web application. This document describes the differences between these two technologies and provides guidance for Web developers about when to use IIS URL rewriting and when to use ASP.NET routing.įrom a high-level perspective, it seems like these technologies provide very similar functionality-both allow your Web applications to have user-friendly and search-engine-friendly URLs. NET Framework 4, there have been a lot of questions from ASP.NET developers about how these two features relate to each other and when you should use one or the other. With the release of the URL Rewrite Module for IIS and the inclusion of ASP.NET routing into the.
0 Comments
Leave a Reply. |