ClientFormsAuthenticationCredentials(String, String, Boolean) 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 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
備註
你通常會將使用者提供的值作為這個建構子的參數傳遞。