views:

231

answers:

2

How would I go about rewriting /path/default.aspx?i=ID to /path/ID/ without the ?i= part of the query url?

A: 

You can do this with an http module in asp.net 1.1/2.0:

http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

ASP.NET 4.0 adds support for URL rewriting natively (it was added as part of 3.5 SP1 but only for ASP.NET MVC, now it's being made available for all ASP.NET apps).

http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx

Sam
A: 

You have several options.

  1. You can use ASP.NET MVC's routing with WebForms if you are in a 3.5 or later environment. I like the straightforward nature of ASP.NET MVC's routing. It's pretty easy to understand and can be unit tested.
  2. You can use ISAPI ReWrite if you are in a 2.0 or later environment. ISAPI Rewrite is RegEx based, and I find it a little tougher to understand than MVC's routing mechanism. Your setup cannot be be unit tested because as the name suggests, it works at the ISAPI.DLL level.
  3. Or, you can do as Sam suggested in use the native stuff with WebForms in ASP.NET 4.0.
Josh Kodroff
Yeah I'm working on a ASP.NET 2.0 environment. I've tried a different rewriting method, I'll try the ISAPI one however.Thanks,Matt
Matt Lima