views:

139

answers:

2

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.

+1  A: 

HttpContext.Current.Request.Url.Host ???

eugeneK
HttpContext.Request.ServerVariables["HTTP_HOST"]; -- done the trick
Piotr Czapla
It doesn't work, It always returns the same value. (ie. It returns localhost even if I access the site using 127.0.0.1 or "Anyotherdomain or ip address")
Piotr Czapla
+1  A: 
string requestedDomain = HttpContext.Current.Request.ServerVariables["HTTP_HOST"];
string requestScheme = HttpContext.Current.Request.Url.Scheme;
string requestQueryString = HttpContext.Current.Request.ServerVariables["QUERY_STRING"];
string requestUrl = HttpContext.Current.Request.ServerVariables["URL"];
Aaron
HttpContext.Request.ServerVariables["HTTP_HOST"] is what i was looking for. Thx
Piotr Czapla