System.Uri.Host Property

Gets the host component of this instance.

Syntax

public string Host { get; }

Value

A string containing the DNS host name or IP address of the host server. If the host information was not specified to the constructor, the value of this property is string.Empty .

Remarks

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

Example

The following example demonstrates using the Uri.Host property.

C# Example

using System;

public class UriTest {
 public static void Main() {

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

The output is

www.contoso.com

Requirements

Namespace: System
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0