views:

195

answers:

6

Is there any way to implement a URL mechanisim in asp.net like it has in asp.net mvc

e.g. mydomain.com/user/myusername but without using the MVC

if so, how?

+4  A: 

You do this by using the System.Web.Routing assembly

Here's a blogpost showing how :-)

l3dx
+2  A: 

You can use the same routing mechanism that ASP.NET MVC uses inside of an ASP.NET WebForm application. Check this post by Phil Haack on how to learn more about it.

or

If you don't want to use the routing feature and you want to roll your own, check this question out.

Dale Ragan
+2  A: 

If you have access to IIS:

  • If it is IIS7, the URL Rewriting module might work.
  • Set IIS up to process ANY request with ASP.NET, and add an entry to Global.ashx

If it is Apache, use mod_rewrite.

Otherwise, you could use:
http://myserver/Web.aspx/url/1 or:
http://myserver/Url.aspx/1 and process Request.Uri.PathInfo

It has to go to a .aspx file somewhere, as otherwise it will not be processed.

Lucas Jones
A: 

I built a classic ASP.NET (I can't believe this term exists) application around 2005 that used rewriting, and this article on MSDN was very helpful at the time: http://msdn.microsoft.com/en-us/library/ms972974.aspx.

If you're constrained to 2.0, or even 1.1, this may be the way to go, as System.Web.Routing is 3.5 only.

Jeremy Frey
+1  A: 

I've done this in the past with ASP.NET 2.0 and the UrlRewrite.Net library

The only trick is that if you want it to work with paths that don't have aspx extensions, you have to configure IIS to pass every request through the ASP.NET engine.

Jason
A: 

IIRF does URL Rewrite for IIS5 and 6. It supports Regex. Free. Open source.

Cheeso