views:

23

answers:

2

Hello, I'm attempting to configure URL routing in my ASP.NET 3.5 WebForms app. Setting up routes has always been confusing to me, so I was hoping I could get some direction.

My requirement is fairly simple. I'm setting up different "brands" of my application, and I'd like the brand to be specified in the URL. For example, http://www.mysite.com/brand1/Default.aspx would bring up one brand (code behind would look up brand1 in the db and load specific text, images, themes, etc) and http://www.mysite.com/brand2/Default.aspx would bring up another brand, etc.

I'm fairly flexible with how the URLs are displayed, with the exception of keeping the http://www.mysite.com/brand1 prefix. That cannot be changed.

Thanks for any help!

+1  A: 

I do this by using http://www.UrlRewriter.net, as explained here by Scott Gu:

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

The trick is to use URL rewriting rules (Regular Expressions) in your web.conifg to get a request for /brand1/default.aspx to actually execute /Processor/Default.aspx?brand=brand1, for example.

NB: The Form.browser trick worked a treat for me when doing postbacks.

TimS
OK, sounds like I had my terminology mixed up when mentioned Routing. I'll check out your link... thanks!
Mike C.
A: 

Another possible answer from me...

If you're using IIS 7 there is a handy built in module for URL Rewiring, all controlled through a GUI if that's your preference:

http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module/

TimS
Using IIS6. Thanks for the info, though.
Mike C.