views:

51

answers:

3

I want to create an asp.net white-label site http://whitelabel.com, that could be styled for each of our clients according to their specific needs. So for example, client abc would see the site in their corporate colours and be accessed through their specific url http://abc.com. Likewise client xyz would see the site in their own styling and url http://xyz.com.

Typing either url, in effect, takes the user to http://whitelabel.com where the styling is applied, and the client's url structure is retained.

I was thinking of URL rewriting using URLRewriter.Net (http://urlrewriter.net/), or similar, mapping the incoming address to a client id and applying the theme accordingly. So, a url rewrite rule may be something like

<rewrite url="http//abc.com/(.+)" to="~/$1?id=1" />

<rewrite url="http//xyz.com/(.+)" to="~/$1?id=2" />

I could then read the id, map it to the client, and with a bit of jiggery-pokery, apply the correct theme.

I was wondering if:

  1. this is the right approach ?
  2. I've overlooked something ?
  3. there is a better way to do this ?

Any suggestions would be appreciated.

A: 

I have seen sites done this way (common codebase, multiple themed sites) but my experiences were with PHP. The code looks at the page's referrer to determine where the user is coming from, and builds the right page.

Domain mapping and masking varies depending on what host you are using...

However it looks like URLRewriter would work for you if you go with ASP, as it would handle masking the domain you are on.

liquidleaf
A: 

You can check the Request.RawUrl property to get back the original URL. So you don't need to add any parameters when you do your rewrite.

Keltex
Doh! Thanks, for pointing that out.
sunil
A: 

You can have multiple domains all running off the same iis site, each with a different themes. You don't even need to rewrite the url.

We point different domains all to the same site using host headers, then we check the host name ...

HttpContext.Current.Request.Url.Host

... in the OnPreInit event in our base page class. Based on the host name we set the page theme, which has all the css and custom images set in the App_Themes

Link to information on setting themes programmatically: http://msdn.microsoft.com/en-us/library/tx35bd89.aspx?PHPSESSID=8415f84585668e69ce791db4abfd0c45

Chris Mullins
I hadn't considered multiple host headers - will definitely give this a try. Thanks
sunil
Tried this and is working a treat. Just wondering, what is the max number of host headers that a site in IIS 7.5 can support?
sunil
I have searched google looking for a limit, and I have not see anything that would suggest that there is a built in limit. The most we have on a single website is 21.
Chris Mullins