July 28, 2014
Gets an unescaped host name that is safe to use for DNS resolution.
Assembly: System (in System.dll)
For IPv6 addresses, the brackets () are removed and the ScopeId property is set, if one was specified when this instance was constructed.
The following example creates a Uri instance from a string. It illustrates the difference between the value returned from Host, which returns the host name or address specified in the URI, and the value returned from , which returns an address that is safe to use in DNS resolution.
// Create new Uri using a string address. Uri address = new Uri("http://[fe80::200:39ff:fe36:1a2d%4]/temp/example.htm"); // Make the address DNS safe. // The following outputs "[fe80::200:39ff:fe36:1a2d]". outputBlock.Text += address.Host; outputBlock.Text += "\n"; // The following outputs "fe80::200:39ff:fe36:1a2d%4". outputBlock.Text += address.DnsSafeHost; outputBlock.Text += "\n";