Get or set the Host header value to use in an HTTP request independent from the request URI.
Assembly: System (in System.dll)
The property can be used to set the Host header value to use in an HTTP request independent from the request URI. The property can consist of a hostname and an optional port number. A Host header without port information implies the default port for the service requested (port 80 for an HTTP URL, for example).
The format for specifying a host and port must follow the rules in section 14.23 of RFC2616 published by the IETF. An example complying with these requirements that specifies a port of 8080 would be the following value for the property:
Using the property to explicitly specify a custom Host header value also affects areas caching, cookies, and authentication. When an application provides credentials for a specific URI prefix, the applications needs to make sure to use the URI containing the value of the Host header, not the target server in the URI. The key used when caching resources, uses the Host header value rather than the request URI. Cookies are stored in a CookieContainer and logically grouped by the server domain name. If the application specifies a Host header, then this value will be used as domain.
If the property is not set, then the Host header value to use in an HTTP request is based on the request URI.