Uri.UserInfo Uri.UserInfo Uri.UserInfo Uri.UserInfo Property

定义

获取用户名、密码或其他与指定 URI 关联的特定于用户的信息。Gets the user name, password, or other user-specific information associated with the specified URI.

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

属性值

一个 String,包含与该 URI 关联的用户信息。A String that contains the user information associated with the URI. 返回值不包括“@”字符,该字符是一个保留字符,用于分隔 URI 的用户信息部分。The returned value does not include the '@' character reserved for delimiting the user information part of the URI.

异常

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

示例

下面的示例创建Uri实例并将用户信息输出到控制台。The following example creates a Uri instance and writes the user information to the console.

Uri^ uriAddress = gcnew Uri( "http://user:password@www.contoso.com/index.htm " );
Console::WriteLine( uriAddress->UserInfo );
Console::WriteLine( "Fully Escaped {0}",
   uriAddress->UserEscaped ? (String^)"yes" : "no" );
Uri uriAddress = new Uri ("http://user:password@www.contoso.com/index.htm ");
Console.WriteLine(uriAddress.UserInfo);
Console.WriteLine("Fully Escaped {0}", uriAddress.UserEscaped ? "yes" : "no");
Dim uriAddress As New Uri("http://user:password@www.contoso.com/index.htm ")
Console.WriteLine(uriAddress.UserInfo)
Console.WriteLine("Fully Escaped {0}", IIf(uriAddress.UserEscaped, "yes", "no")) 'TODO: For performance reasons this should be changed to nested IF statements

注解

返回此属性的值通常是中"用户名: 密码"的格式。The value returned by this property is usually in the format "userName:password".

适用于