Export (0) Print
Expand All

Uri.HostNameType Property

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

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

public UriHostNameType HostNameType { get; }

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.

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);

.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

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

Portable Class Library

Supported in: Portable Class Library
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft