Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is Request.ServerVariables["HTTP_HOST"] different from Request.Url.Host?

Tags:

c#

asp.net

Same server, same site - two different results.

Case 1

request URL: domain.com (resolving to domain.com/default.aspx)
request header in Firebug: domain.com
Request.ServerVariables["HTTP_HOST"] = domain.com
Request.Url.Host = domain.com (Ok, this is good and expected)

Case 2

request URL: domain.com/default.aspx
request header in Firebug: domain.com
Request.ServerVariables["HTTP_HOST"] = domain.com
Request.Url.Host = app5 (name of the server)

Looking at two requests I can't see anything that would cause that. Why would this be the case?
Server is running Windows 2003 and IIS6.

like image 559
Ilia G Avatar asked Jun 01 '12 14:06

Ilia G


1 Answers

you should check whether the IIS metabase is setup to use the hostname or a different name

command -> cscript adsutil.vbs get W3SVC/SITE-ID/USEHOSTNAME

Result -> should be

The parameter "USEHOSTNAME" is not set at this node.

or USEHOSTNAME : (BOOLEAN) False

command -> cscript adsutil.vbs get W3SVC/SITE-ID/SETHOSTNAME

Result -> should be

The parameter "SETHOSTNAME" is not set at this node.

or SETHOSTNAME : (STRING) ""

change SITE-ID with the numeric id of the site.

If you see any other result that means somebody has modified the above two properties of the site.

like image 120
user2409395 Avatar answered Nov 06 '22 08:11

user2409395