Uri.Authority 属性
定义
获取服务器的域名系统 (DNS) 主机名或 IP 地址和端口号。Gets the Domain Name System (DNS) host name or IP address and the port number for a server.
public:
property System::String ^ Authority { System::String ^ get(); };
public string Authority { get; }
member this.Authority : string
Public ReadOnly Property Authority As String
属性值
此实例所表示的 URI 的颁发机构组件。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");
Console.WriteLine(myUri.Authority);
Dim baseUri As New Uri("http://www.contoso.com:8080/")
Dim myUri As New Uri(baseUri,"shownew.htm?date=today")
Console.WriteLine(myUri.Authority)
注解
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.