Uri.HostNameType Property

Gets the type of the host name specified in the URI.

Namespace:  System
Assembly:  System (in System.dll)

'Declaration
Public ReadOnly Property HostNameType As UriHostNameType

Property Value

Type: System.UriHostNameType
A member of the UriHostNameType enumeration.

ExceptionCondition
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.

Dim address1 As New Uri("http://www.contoso.com/index.htm#search")
Console.WriteLine("address 1 {0} a valid scheme name", IIf(Uri.CheckSchemeName(address1.Scheme), " has", " does not have")) 'TODO: For performance reasons this should be changed to nested IF statements

If address1.Scheme = Uri.UriSchemeHttp Then
    Console.WriteLine("Uri is HTTP type")
End If 
Console.WriteLine(address1.HostNameType)

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft