Uri.Authority Property


Gets the Domain Name System (DNS) host name or IP address and the port number for a server.

 property System::String ^ Authority { System::String ^ get(); };
public string Authority { get; }
member this.Authority : string
Public ReadOnly Property Authority As String

Property Value

The authority component of the URI represented by this instance.


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


The following example writes the host name ( and port number (8080) of the server to the console.

Uri^ baseUri = gcnew Uri( "" );
Uri^ myUri = gcnew Uri( baseUri,"shownew.htm?date=today" );
Console::WriteLine( myUri->Authority );
Uri baseUri = new Uri("");
Uri myUri = new Uri(baseUri,"shownew.htm?date=today");

open System

let baseUri = Uri ""
let myUri = Uri(baseUri, "shownew.htm?date=today")

printfn $"{myUri.Authority}"
Dim baseUri As New Uri("")
Dim myUri As New Uri(baseUri,"shownew.htm?date=today")


The Authority property is typically a server DNS host name or IP address. This property might include the service port number if it differs from the default port for the URI. If the Authority component contains reserved characters, these are escaped in the string value returned by this property.

Applies to