Er. alokpandey's Blog

Differences between URL Rewriting and ASP.NET Routing

Posted in ASP.NET (C# & VB), C#, SEO, VB by Alok Kumar Pandey on February 14, 2010

Based on the above explanation you can see that the main conceptual differences between URL rewriting and ASP.NET routing are the following:

  1. URL rewriting is used to manipulate URL paths before the request is handled by the Web server. The URL-rewriting module does not know anything about what handler will eventually process the rewritten URL. In addition, the actual request handler might not know that the URL has been rewritten.
  2. ASP.NET routing is used to dispatch a request to a handler based on the requested URL path. As opposed to URL rewriting, the routing component knows about handlers and selects the handler that should generate a response for the requested URL. You can think of ASP.NET routing as an advanced handler-mapping mechanism.

In addition to these conceptual differences, there are the following functional differences between IIS URL rewriting and ASP.NET routing:

  1. The IIS URL-rewrite module can be used with any type of Web application, which includes ASP.NET, PHP, ASP, and static files. ASP.NET routing can be used only with .NET Framework-based Web applications.
  2. The IIS URL-rewrite module works the same way regardless of whether integrated or classic IIS pipeline mode is used for the application pool. For ASP.NET routing, it is preferable to use integrated pipeline mode. ASP.NET routing can work in classic mode, but in that case the application URLs must include file extensions or the application must be configured to use “*” handler mapping in IIS.
  3. The URL-rewrite module can make rewriting decisions based on domain names, HTTP headers, and server variables. By default, ASP.NET routing works only with URL paths and with the HTTP-Method header.
  4. In addition to rewriting, the URL-rewrite module can perform HTTP redirection, issue custom status codes, and abort requests. ASP.NET routing does not perform those tasks.
  5. The URL-rewrite module is not extensible in its current version. ASP.NET routing is fully extensible and customizable.

Which Option Should You Use?

What does all this information mean if you need to choose a technology in order to enable clean URLs for your Web applications? In this section we will explain how to make this choice.

First of all, if your Web application is built by using anything except ASP.NET, the choice is obvious: use the IIS URL-rewrite module. Otherwise, the rules of thumb are:

  1. If you are developing a new ASP.NET Web application that uses either ASP.NET MVC or ASP.NET Dynamic Data technologies, use ASP.NET routing. Your application will benefit from native support for clean URLs, including generation of clean URLs for the links in your Web pages. Note that ASP.NET routing does not support standard Web Forms applications yet, although there are plans to support it in the future.
  2. If you already have a legacy ASP.NET Web application and do not want to change it, use the URL-rewrite module. The URL-rewrite module allows you to translate search-engine-friendly URLs into a format that your application currently uses. Also, it allows you to create redirect rules that can be used to redirect search-engine crawlers to clean URLs.

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 when you may want to use ASP.NET routing and IIS URL rewriting together.

Advertisements

2 Responses

Subscribe to comments with RSS.

  1. ASP.NET MVC Archived Blog Posts, Page 1 said, on February 17, 2010 at 7:24 pm

    […] to VoteDifferences between URL Rewriting and ASP.NET Routing (2/13/2010)Saturday, February 13, 2010 from eralokpandeyBased on the above explanation you can see that the […]

  2. bigman said, on March 6, 2010 at 3:27 pm

    nice tuto in here , good introduction , look at mine in my website righ here http://help.uk.cm.

    hear from you soon thanks


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: