简体   繁体   English

为什么Request.ServerVariables [“HTTP_HOST”]与Request.Url.Host不同?

[英]Why is Request.ServerVariables[“HTTP_HOST”] different from Request.Url.Host?

Same server, same site - two different results. 相同的服务器,同一站点 - 两个不同的结果。

Case 1 情况1

request URL: domain.com (resolving to domain.com/default.aspx) 请求URL:domain.com(解析为domain.com/default.aspx)
request header in Firebug: domain.com Firebug中的请求标头:domain.com
Request.ServerVariables["HTTP_HOST"] = domain.com Request.ServerVariables["HTTP_HOST"] = domain.com
Request.Url.Host = domain.com (Ok, this is good and expected) Request.Url.Host = domain.com(好的,这是好的和预期的)

Case 2 案例2

request URL: domain.com/default.aspx 请求URL:domain.com/default.aspx
request header in Firebug: domain.com Firebug中的请求标头:domain.com
Request.ServerVariables["HTTP_HOST"] = domain.com Request.ServerVariables["HTTP_HOST"] = domain.com
Request.Url.Host = app5 (name of the server) Request.Url.Host = app5 (服务器名称)

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. 服务器正在运行Windows 2003和IIS6。

you should check whether the IIS metabase is setup to use the hostname or a different name 您应该检查IIS元数据库是否设置为使用主机名或其他名称

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

Result -> should be 结果 - >应该是

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

or USEHOSTNAME : (BOOLEAN) False USEHOSTNAME : (BOOLEAN) False

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

Result -> should be 结果 - >应该是

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

or SETHOSTNAME : (STRING) "" SETHOSTNAME : (STRING) ""

change SITE-ID with the numeric id of the site. 使用站点的数字ID更改SITE-ID。

If you see any other result that means somebody has modified the above two properties of the site. 如果您看到任何其他结果,则表示有人修改了网站的上述两个属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么HttpContext.Request.Url和Request.ServerVariables [“ HTTP_HOST”]返回不同的值 - why does HttpContext.Request.Url and Request.ServerVariables[“HTTP_HOST”] return different values Request.ServerVariables [“ HTTP_HOST”]。ToString()是否可能返回与我在网址栏中看到的主机不同的主机 - Is it possible that Request.ServerVariables[“HTTP_HOST”].ToString() can return a different host than what I see in the url bar 在一次调用中Request.Url.Host和ApplicationPath - Request.Url.Host and ApplicationPath in one call Request.Url.Host 是否包含子域? - Does Request.Url.Host include the subdomain? 为什么Request [“host”] ==“dev.testhost.com:1234”而Request.Url.Host ==“localhost” - Why does Request[“host”] == “dev.testhost.com:1234” whereas Request.Url.Host == “localhost” Request.Url.Host vs Request.Url.Authority - Request.Url.Host vs Request.Url.Authority Request.ServerVariables函数 - Request.ServerVariables in function .Request.Url.Host不显示子域 - .Request.Url.Host doesn't show subdomain Request.ServerVariables抛出NullReferenceException - Request.ServerVariables throws NullReferenceException 在request.servervariables()中添加自定义标头 - Add custom header in request.servervariables()
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM