views:

567

answers:

4

Hi, I am making a making a new asp.net web forms site and would like to beautify my urls - I want to accept a url like this one "www.mysite.com/1-2,3" and turn it one like this "www.mysite.com/page.aspx?a=1&b=2&c=3". Which option is best for this task - IIS7 Url Rewriting or Routing in terms of performance and ease of maintenance. Btw I am planning to use medium trust shared hosting IIS7, maybe 6.

In the past I used PHP's mod_rewrite, which I was quite happy with, however now this whole site is being translated to ASP.NET, and I don't know which option to pick.

PS - I have already read this and this, however didn't find it clear enough for my problem.

A: 

IIS 5/6 used ISAPI filtering which was basically the equivalent of mod_rewrite for IIS. I hear that IIS7's url rewriting is a lot easier to manage and configure than ISAPI.

Rob Stevenson-Leggett
A: 

Well it depends on whether you're using classic ASP.Net or the new MVC framework. I don't have any experience with the MVC framework, but it sounds like it supports what you're looking for right out of the box.

On the classic ASP.Net side of things, we're currently using an IIS extension called ISAPI_Rewrite. It behaves similarly to Apache's mod_Rewrite and they have a free version you can use that has most of the power of the paid version ($100).

Jason
learned a lot about MVC today and it seems super easy to "beautify" urls w/this framework
Jason
Routing is a separate entity from MVC. MVC simply uses routing, just as WebForms can.
Rex M
+4  A: 

I would make a strong argument for using routing. It keeps the request-resource resolution logic within your application, so it's very easy to add application-dependent logic when you need, and it eliminates the need to maintain synchronization between your application and a separate configuration resource.

Routing works great with traditional webforms.

URL rewriting is often (though not always) a compensation for a problem, rather than a solution - server software and frameworks still built around the older notion of web pages, which represent physical resources. However, web applications should react to requests as commands; but only relatively recent, modern web frameworks have begun to support that model natively. Routing is one of those developments.

Rex M
+1  A: 

I would strongly suggest to use routing, it will in fact be more integrated with webforms in next version of the framework. URL rewriting is more of a "hack" due to the lack of the routing in the first place. If you already have a project that you want to "shine up", then url rewriting will do just fine.

But when starting from scratch, I would definitely use routing.

Routing hides you application structure and makes you think more of your urls, as path to the content that you want to show, opposed to the path to some page with params. And you don't have to keep track of 2 things when changing stuff, like you would with rewriting.

more in this article

Cshift3iLike