With the release of the URL Rewrite Module for IIS and the inclusion of ASP.NET routing into the .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. 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.
From 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.
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.
To help you understand those differences, we will first explain how IIS URL rewriting and ASP.NET routing work.
Based on the above explanation, there are the following main conceptual differences between IIS URL rewriting and ASP.NET routing:
In addition to these conceptual differences, there are the following functional differences between IIS URL rewriting and ASP.NET routing:
What does all this information mean if you need to choose a technology to enable clean URLs for your Web applications? In this section, we explain how to make this choice.
If your Web application is built by using anything except ASP.NET, use the IIS URL Rewrite module. Otherwise, the rules are:
In practice, however, the choice does not have to be either/or. The technologies can be used together and can complement each other. In the following sections, we outline some scenarios where you can use ASP.NET routing and IIS URL rewriting together.
Enforcing canonical URLs for your application.
You should force the use of http://www.mysite.com/home/about instead of http://mysite.com/Home/About.
When a Web client requests a URL that does not conform to the format
that you want, the client is redirected to a canonical URL. In this
scenario, you can use the URL Rewrite module to enforce canonical URLs
and perform redirection, and use ASP.NET routing to select a handler
that would process the requested URL path.
Either IIS URL rewriting or ASP.NET routing can be used to implement URL manipulation scenarios for your Web application.
ASP.NET routing is a solution that is optimized for ASP.NET, thus it may be preferable for Web developers who design their ASP.NET applications from the ground up and want to have a clean URL structure.
IIS URL rewriting is a generic URL manipulation mechanism that addresses a multitude of scenarios.
In particular, it can be used by Web developers as well as Web server/site administrators to enable clean URLs for existing Web applications without modifying the application code.
IIS URL Rewriting and ASP.NET Routing
原文:https://www.cnblogs.com/chucklu/p/11512080.html