Uri.Host Property


Gets the host component of this instance.

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

public string Host { get; }

Property Value

Type: System.String

A String that contains the host name. This is usually the DNS host name or IP address of the server.

Exception Condition

This instance represents a relative URI, and this property is valid only for absolute URIs.

Unlike the Authority property, this property value does not include the port number.

The following example writes the host name (www.contoso.com) of the server to the console.

Uri baseUri = new Uri("http://www.contoso.com:8080/");
Uri myUri = new Uri(baseUri, "shownew.htm?date=today");


Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top