語言

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

備註

你通常會將使用者提供的值作為這個建構子的參數傳遞。

適用於

另請參閱