Uri.UserInfo Property

Definition

取得與指定 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

Property Value

String

String,包含 URI 相關聯的使用者資訊。A String that contains the user information associated with the URI. 傳回值不包含 'The returned value does not include the " data-throw-if-not-resolved="False" data-raw-source="@' 保留字元,它是用來分隔 URI 的使用者資訊部分。</span><span class="sxs-lookup"><span data-stu-id="05b77-1086">The returned value does not include the '" sourceFile="api/System.Uri.UserInfo.yml" sourceStartLineNumber="1">@' character reserved for delimiting the user information part of the URI.

Exceptions

這個執行個體代表相對的 URI,而這個屬性只適用於絕對 URI。This instance represents a relative URI, and this property is valid only for absolute URIs.

Examples

下列範例會建立 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

Remarks

這個屬性所傳回的值通常採用 "userName: password" 格式。The value returned by this property is usually in the format "userName:password".

Applies to