ClientFormsAuthenticationCredentials(String, String, Boolean) 建構函式

定義

初始化 ClientFormsAuthenticationCredentials 類別的新執行個體。

public:
 ClientFormsAuthenticationCredentials(System::String ^ username, System::String ^ password, bool rememberMe);
public ClientFormsAuthenticationCredentials (string username, string password, bool rememberMe);
new System.Web.ClientServices.Providers.ClientFormsAuthenticationCredentials : string * string * bool -> System.Web.ClientServices.Providers.ClientFormsAuthenticationCredentials
Public Sub New (username As String, password As String, rememberMe As Boolean)

參數

username
String

使用者名稱。

password
String

使用者密碼。

rememberMe
Boolean

指出使用者認證是否應儲存並重複用於後續登入嘗試的值。

範例

下列範例程式代碼示範如何實 IClientFormsAuthenticationCredentialsProvider.GetCredentials 作 方法,這個方法會傳回這個類別的實例。 在此範例中 GetCredentials ,此方法是登入對話框類別的一部分。 方法會顯示對話框,然後傳回 ClientFormsAuthenticationCredentials 以使用者指定值初始化的實例。

public ClientFormsAuthenticationCredentials GetCredentials()
{
    if (this.ShowDialog() == DialogResult.OK)
    {
        return new ClientFormsAuthenticationCredentials(
            usernameTextBox.Text, passwordTextBox.Text,
            rememberMeCheckBox.Checked);
    }
    else
    {
        return null;
    }
}
Public Function GetCredentials() As  _
    ClientFormsAuthenticationCredentials Implements _
    IClientFormsAuthenticationCredentialsProvider.GetCredentials

    If Me.ShowDialog() = DialogResult.OK Then
        Return New ClientFormsAuthenticationCredentials( _
            UsernameTextBox.Text, PasswordTextBox.Text, _
            rememberMeCheckBox.Checked)
    Else
        Return Nothing
    End If

End Function

備註

您通常會傳遞使用者提供的值作為這個建構函式的參數。

適用於

另請參閱