views:

157

answers:

2

Hi,

I have a ASP.Net MVC application which serves user pages with URL like -

www.myapp.com/user/rob/index,
www.myapp.com/user/rob/article/1

and

www.myapp.com/user/scott/index,
www.myapp.com/user/scott/article/1

now I want this one application to serve pages to two different domains from outside. Like -

www.RobWebSite.com/Index
www.RobWebSite.com/article/1

www.scottBlogSiteNoOne.com/Index
www.ScottBlogSiteNoOne.com/article/1

what kind of setup / redirects / proxies I will need to setup so when user types the published domain name (www.RobWebSite.com) it translates internally to my app as (www.myapp.com/user/rob/). I want to keep the url in the browser the same what they typed, while just query string parameters changes.

Thanks and Regards,
Ajay

+1  A: 

Each users' domain name will need a CNAME record in their DNS that points to myapp.com. (Google uses CNAME records to point custom domain names to Blogger.com blogs, so that seems like a good way to go.)

Then your code needs to look at the Request object to identify which domain name is being used and do a lookup to find which user the domain belongs to. This wouldn't really be translating to myapp.com/user/name/. It would be using the domain name to determine the user instead of the route parsing that you would normally do with MVC.

I'm not 100% sure that the Request object will give you the right domain name. You'll have to try it out.

Dennis Palmer
thanks for the reply. Can you point me to any extra information/material which might help me to decide this? Thanks.
Ajay
thanks. this helped me a lot.
Ajay
A: 

You could also just setup your code so that your urls specify relative paths rather than absolute URLs. This will keep the domain name the same in the browser and improve performance.

EricLaw -MSFT-