IIS URL Redirection and URL Routing

I planned to use URL routing for a Web Forms application. But after reading some posts , I'm not sure if this is a simple approach.

Is it better to use the Rewrite module URL for web forms? But this is only for IIS7. Initially, there was some animation that URL routing was completely disconnected from Asp.Net MVC and could be used for web forms.

I would like to hear any suggestions.

+46
url-rewriting asp.net-mvc iis routing
Sep 18 '08 at 4:45
source share
7 answers

There's a great article here about the differences between them from a member of the IIS team.

One caveat I would advise is that for WebForms you need to be careful when using routing. I wrote an example implementation of how you will use routing with WebForms , which fixes these problems and hopefully helps answer your question.

+24
Sep 18 '08 at 15:55
source share

This is the best article I have found on this topic: Rewriting IIS URLs and ASP.NET Routing Ruslan Yakushev.

IIS URL Redirection

When a client makes a request to a web server for a specific URL, the URL rewrite component parses the requested URL and changes it to another URL on the same server. The URL rewrite component runs very early in the request processing pipeline, so it can modify the requested URL before the web server decides which processor should use it to process the request.

IIS URL Rewriting

ASP.NET Routing

ASP.NET routing is implemented as a managed code module that connects to the IIS request pipeline at the Decisive Cache Level stage (PostResolveRequestCache event) and at Map Handler (PostMapRequestHandler) stage. ASP.NET routing is configured to run for all requests made in a web application.

IIS URL Routing

Differences between URL rewriting and ASP.NET routing:

  • URL rewriting is used to manage URLs before the request is processed by the web server . The URL rewrite module is unaware that the handler will eventually process the rewritten URL. In addition, the actual request handler may not know that the URL has been rewritten.
  • ASP.NET routing is used to send a request to a handler based on the requested URL . Unlike rewriting a URL, the routing component knows about the handlers and selects the handler that should generate the response for the requested URL. You can consider ASP.NET routing as an advanced handler mapping mechanism.

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

  • The IIS URL Rewrite Module can be used with any type of web application that includes ASP.NET, PHP, ASP, and static files. ASP.NET routing can only be used with .NET Framework-based web applications.
  • The IIS URL Rewriter works the same way, regardless of whether the application pool uses integrated or classic IIS pipeline mode. For ASP.NET routing, it is preferable to use the native pipeline mode. ASP.NET routing can work in classic mode, but in this case, application URLs must include file extensions or the application must be configured to use the "*" handler in IIS.
  • The URL rewrite module can make rewriting decisions based on domain names, HTTP headers, and server variables. By default, ASP.NET routing only works with URLs and with the HTTP-Method header.
  • In addition to rewriting, the URL rewriter can perform HTTP redirection, issue custom status codes, and interrupt requests. ASP.NET routing does not perform these tasks.
  • The URL rewrite module is not expandable in the current version. ASP.NET routing is fully extensible and customizable.
+36
Nov 08 '08 at 18:55
source share

Do you want formatted URLs to be a factory for spawning pages?

or do you want .aspx to go away?

rewriting, is to make .aspx go away or just remove the url.

Routing is the search for a request and determining which object should process it. They sound the same; the Phil House has some good articles on the subject.

in iis6, isapiRewrite, very good

+7
Sep 18 '08 at 4:47
source share

Recently, I just wrote my own rewriting system to make the URLs on my sites better. Basically, you will need to write your own IHttpModule and add it to your web.config to intercept incoming requests. Then you can use HttpContext.Current.RewritePath to change what you point to.

You will also want to set your site to use aspnet_isapi for everything .

You will find many small problems along the way, for example, trying to work with pages that use β€œtails” on them (for example, for PageMethods) or by moving page elements and generating callbacks, but you will go through them.

If interested, I can post a link to the code, and you can check it out. I already worked hard on problems, so you can read this when you go. I am sure that there are many other people who have done this, as well as good resources.

+4
Sep 18 '08 at 14:23
source share

You can check my answer to this question: ASP.NET - creating your own routing system . I am including some useful links to help create my own routing system using the URL rewriting method or a new routing mechanism that you can use that came out of the ASP.NET MVC project.

+2
Sep 18 '08 at 14:08
source share

The Dynamic Data project, available with .Net 3.5 SP1, provides a good example of implementing URL routing.

0
Sep 18 '08 at 4:48
source share

To rewrite URLs in IIS, IIRF works in IIS5, 6, 7. Free. Easily. Quickly. Open source. Regular expression support.

0
Mar 09 '09 at 7:15
source share



All Articles