Uri.UserInfo Property

Definition

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

The user information associated with the URI. The returned value does not include the '@' character reserved for delimiting the user information part of the URI.

Exceptions

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

Examples

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");
let uriAddress = Uri "http://user:password@www.contoso.com/index.htm "
printfn $"{uriAddress.UserInfo}"
printfn $"""Fully Escaped {if uriAddress.UserEscaped then "yes" else "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

The value returned by this property is usually in the format "userName:password".

Applies to