Why does Request[“host”] == “dev.testhost.com:1234” whereas Request.Url.Host == “localhost”

后端 未结 3 527
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-05 10:41

Hi all, I seem to have found a discrepancy when testing ASP.NET applications locally on the built-in web server with Visual Studio 2008 (Cassini).

I\'ve

3条回答
  •  说谎
    说谎 (楼主)
    2021-02-05 11:43

    It's a matter of what the w3 specs say versus what the Microsoft Uri.Host property is supposed to contain. The naming does not imply an attempt by MS to provide identical functionality. The function that does include port numbers is Uri.Authority.

    With the update you posted, you're still facing the same problem, just examining a different aspect of it. The Uri.Host property is not explicity or implicity stated to perform the same function as the headers that are defined in the w3 specs. In long form, here are some quotes from the Uri.Host MSDN page:

    Uri.Host Property
    Gets the host component of this instance.

    Property Value

    Type: System.String

    A String that contains the host name. This is usually the DNS host name or IP address of the server.

    There's no guarantee that this will match what is in the headers, just that it represents the host name in some form.

提交回复
热议问题