The new version Url-rewrite module for IIS 7.0 was released, and the ASP.net routing component was further developed in the. NET Framework SP1 Beta with the release of the. NET Framework 3.5 4.0. As ASP.net developers, we have a lot of questions about these two functionally similar components, such as "What are their similarities and differences?" "What is the environment that applies to each?" Wait The purpose of this article is to describe the similarities and differences between the two, and to provide developers with recommendations on when to use which solution.
On the face of it, both technologies seem to offer very similar features: a user-friendly, search-friendly URL for the site. However, there is an essential difference between the two technologies in principle, which requires a deep understanding to make the right decisions when choosing applications. To help you understand both technologies, let's start with their principles of operation.
This article is translated from the official website of IIS and has been partially adjusted for domestic usage.
URL rewrite (URL rewriting)
URL rewriting is no longer a new technology, and has been widely used on Apache servers around 10 years ago. Because it is recognized as a magic weapon for Web administrators and developers, many popular Apache based sites rely on URL rewriting to provide "elegant" URLs.
Simply put, the idea of URL rewriting is simple: When a client requests a specific URL to the server, the URL rewrite module analyzes the requested URL and changes the request to another URL on the same web. Inserting a URL rewrite module (such as through HttpModule) in a Web request cycle is very simple, so it can modify the requested URL before the server processes the request. The server-side handler generates a response to the client browser based on the rewritten URL. Because the rewrite process occurs on the server side, the client browser simply does not see the rewritten URL, and in the view of the client, the response received from the originally requested URL.
In the architecture of IIS 7.0, this process can be demonstrated by the following illustration:
The URL rewrite module (url-rewrite module) provided by Microsoft is a Native-code module that inserts the PRE-BEGIN request or begin request phase of the Web requests process and then passes A series of overridden rules that are configured for URL rewriting. Each rewrite rule makes a regular analysis of the URL, determining whether the currently requested URL satisfies the condition defined by the rewrite rule and, if it is satisfied, rewrites the original URL to a new URL according to the rule. When all rewrite rules are passed, the URL rewrite module generates a final URL path that is passed to the remaining request processing process. This means that the request handler in the IIS pipeline handles the URL that is written after the URL rewrite module.