'How to get "Host:" header from HttpContext (asp.net)

I need to server parts of my application from different domains. To be precise I have a sub section of the site that should be served from a region specific domain. For example:

  • /fr/* should be served from www.domain.fr
  • /uk/* should be serverd from www.domain.co.uk and so on.

I'd like to make a route entry that will redirect the request with wrong domain to the correct domain. But I don't know how to access http header information form HttpContext.

Any help is welcome.



Solution 1:[1]

HttpContext.Current.Request.Url.Host

Solution 2:[2]

I think you want Request.Headers["host"]

Solution 3:[3]

In some cases you want to know from the host who sent de request, so I used this

 stsring _Host = HttpContext.Request.Headers["Referer"];

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Brunno
Solution 2 Mild Fuzz
Solution 3 Ruben