Ilia G
Ilia G

Reputation: 10221

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

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.

Upvotes: 7

Views: 8738

Answers (1)

user2409395
user2409395

Reputation: 21

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.

Upvotes: 2

Related Questions