0

While attemtping to debug some old website, I've been banging my head against a rather ridiculous wall.

In my HOSTS file, I have

127.0.0.1 local.dev.site.tld

When I navigate it in my browser, Request.Url.Host keeps being localhost instead of local.dev.site.tld

This is needed to determine things like language, like if .tld is .de == Germany or .dk == Denmark. Unfortunately I cannot change all the calls to Request.Url.Host. But it should just work, shouldn't it..?

Some say it's the browser's "fault", cause it'd have localhost in the host-header, but Fiddler tells me that said header is local.dev.site.tld.

My google-foo isn't very strong, so forgive me if I've missed some obvious solution or SO post.

So, how do I make the right hostname appear in Request.Url.Host?

Heki
  • 854
  • 2
  • 14
  • 30
  • 1
    possible duplicate of [Why does Request\["host"\] == "dev.testhost.com:1234" whereas Request.Url.Host == "localhost"](http://stackoverflow.com/questions/1941522/why-does-requesthost-dev-testhost-com1234-whereas-request-url-host) – CodeCaster Feb 24 '14 at 10:38
  • I've had a look at that one, but I don't have that Cassini thing and it didn't otherwise yield anything usefull. The solution isn't viable anyway. – Heki Feb 24 '14 at 10:40
  • Do you use IIS Express? Does `Request.Headers["host"]` contain the correct value? – CodeCaster Feb 24 '14 at 10:42
  • No, just the built in one in VS. – Heki Feb 24 '14 at 10:43
  • That is either IIS Express or ASP.NET Development Server, and [both seem to suffer from this](http://stackoverflow.com/questions/2513216/test-multiple-domains-using-asp-net-development-server). – CodeCaster Feb 24 '14 at 10:43
  • 1
    How absolutely horrible.. ``Request.Headers["host"]`` is right, but ``Request.Url.Host`` isn't. This opens up a world of hurt, cause I'm blessed with SiteCore and some other things. – Heki Feb 24 '14 at 10:48

0 Answers0