This documentation is archived and is not being maintained.

Uri.Host Property

Gets the Domain Name System (DNS) host name, or IP address of the server specified in the URI.

[Visual Basic]
Public ReadOnly Property Host As String
[C#]
public string Host {get;}
[C++]
public: __property String* get_Host();
[JScript]
public function get Host() : String;

Property Value

A string containing the DNS host name or IP address of the server.

Remarks

The Host property gets the fully qualified DNS host name or IP address of the server specified in the URI.

Example

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

[Visual Basic] 
Dim baseUri As New Uri("http://www.contoso.com:8080/")
Dim myUri As New Uri(baseUri,"shownew.htm?date=today")
       
Console.WriteLine(myUri.Host)


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

[C++] 
Uri* baseUri = new Uri(S"http://www.contoso.com:8080/");
Uri* myUri = new Uri(baseUri, S"shownew.htm?date=today");
 
Console::WriteLine(myUri->Host);

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

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

Uri Class | Uri Members | System Namespace

Show: