Uri.Authority Uri.Authority Uri.Authority Uri.Authority Property


获取服务器的域名系统 (DNS) 主机名或 IP 地址和端口号。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


包含此实例所表示的 URI 的证书颁发机构部分的 StringA String containing the authority component of the URI represented by this instance.


此实例代表一个相对 URI,而此属性仅对绝对 URI 有效。This instance represents a relative URI, and this property is valid only for absolute URIs.


下面的示例将主机名称 (www.contoso.com) 和端口号 (8080) 到控制台的服务器。The following example writes the host name (www.contoso.com) and port number (8080) of the server to the console.

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

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


Authority属性通常是服务器 DNS 主机名或 IP 地址。The Authority property is typically a server DNS host name or IP address. 此属性可能包括服务端口号,如果它不同于默认端口为 URI。This property might include the service port number if it differs from the default port for the URI. 如果Authority组件包含保留的字符,这些转义中此属性返回的字符串值。If the Authority component contains reserved characters, these are escaped in the string value returned by this property.