Uri.HostNameType Property
.NET Framework 4.5
Gets the type of the host name specified in the URI.
Assembly: System (in System.dll)
| Exception | Condition |
|---|---|
| InvalidOperationException | This instance represents a relative URI, and this property is valid only for absolute URIs. |
The following example creates a Uri instance and writes the HostNameType to the console.
Uri address1 = new Uri("http://www.contoso.com/index.htm#search"); Console.WriteLine("address 1 {0} a valid scheme name", Uri.CheckSchemeName(address1.Scheme) ? " has" : " does not have"); if (address1.Scheme == Uri.UriSchemeHttp) Console.WriteLine("Uri is HTTP type"); Console.WriteLine(address1.HostNameType);
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.