When I deployed my application on the server I faced this issue:
Request.Url.ToString();
returns the machine name instead of the domain name.
For example:
Instead of returning http://www.domainName.com/default.aspx
it returns http://appserver-01/default.aspx
.
Note: Everything was OK before the deployment.
It sounds like it could be one or more of the following:
your server is sitting behind a firewall and/or load balancer that are stripping the
Host:
header from the request.Check the IIS configuration - the binding list should include both
domainName.com
andwww.domainName.com
instead of being blank (default site).Are you making the requests from inside or outside your company network? The network administrator may have configured internal DNS differently than the external DNS.
Drop this code as
ServerVariables.aspx
somewhere on your site (temporarily: it exposes server configuration info) and it will dump the request headers: