views:

203

answers:

2

So the basic premise to this problem is that I have a single hosted webspace which came with two domain names. I am unsure how to configure routing in asp.net mvc so that the first thing I would check would be this host in the request object so that I can more user traffic to two separate parts of my website.

For example:

http://www.mywebsite1.com/products/14

http://www.mywebsite2.com/products/14

How do you route so that those two url's above end up returning two different pages based on the context of the host used in the request?

Thanks in advance!

+1  A: 

You need to implement a custom view engine that will look at the URL post controller execute and select the correct view.

Check this out for more info: Asp.Net Themes

A: 

You can also use some kind of URL rewriting in IIS7 or whatever you use, because it can access the domain name part too. For example you can create a rewrite method that injects the domain name into the url, like:

http//www.example1.org/Something/1 --> http//www.example1.org/example1/Something/1 http//www.example2.org/Something/1 --> http//www.example2.org/example2/Something/1

And because now the domain name is in the URL string, you can use the default routing engine to send this information to the controllers or do something else.

SztupY