tags:

views:

57

answers:

3

Hi

We have multiple domains for one of our websites.

e.g. mydomain-uk.com and mydomain.co.uk

I have a handler which creates an XML sitemap and it uses HttpContext.Current.Request.Url.Host to retrieve the host site.

When my browser is on mydomain.co.uk/handler it retrieves mydomain-uk.com as the host

How can I ensure it always retrieves mydomain.co.uk ?

Is there a preference order configured somewhere on the server?

+1  A: 

The host is get it from the URL on the request, and this is logical, you can not change this.

To solve this, create a static variable with your URL name, even better place it on your web.config, and just get this variable and not the Url.Host

Hope this help

Aristos
A: 

Don't point all of your domains at the website. Have the extra domains perform a 301 redirect to the main domain name. This will also help resolve confusion by search engines when they try to resolve your site as to which site is the original source of your content, and will prevent inbound links from other websites from using a mixture of domains which will only exacerbate the problem.

Nathan Ridley
A: 

Don't forget that HttpContext.Current.Request.Url.Host is simply going to return whatever HOST was requested at the time it happened. If the client requested something else, HttpContext.Current.Request will reflect this.

m.edmondson