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).
Sam
2010-01-22 15:57:04
A:
You have several options.
- 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.
- 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.
- Or, you can do as Sam suggested in use the native stuff with WebForms in ASP.NET 4.0.
Josh Kodroff
2010-01-22 17:00:50
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
2010-01-24 17:57:28