Hosts file hostname not being returned in c# ASP.NET MVC
I think, original host is lost after mapping of domain to IP-adress (localhost) by local operating system with your "host" file.You can try RawUrl instead to retrieve exact URL typed in browser:
HttpContext.Current.Request.RawUrl
Also you can try to fetch HTTP_HOST
variable from user Host:
request header, it should contain original host (not address or default host of the server) browser tries to request:
string requestedDomain = HttpContext.Current.Request.ServerVariables["HTTP_HOST"];
Maybe Getting parameters from RawUrl article will be helpful.