How can i edit my snippet to do this ?
To the corresponded code-behind file: Default.aspx.cs
, move this code:
private bool SiteSpecificAuthenticationMethod(string UserName, string Password)
{
// Insert code that implements a site-specific custom
// authentication method here.
//
// This example implementation always returns false.
return false;
}
protected void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
bool Authenticated = false;
Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);
e.Authenticated = Authenticated;
}
UPDATE
Change the OnAuthenticate
access-modifier to protected
:
protected void OnAuthenticate(object sender, AuthenticateEventArgs e)
{
bool Authenticated = false;
Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password);
e.Authenticated = Authenticated;
}
Is it the best way to add a customized authentification form?
Yes, if you want to customize the authentication process, I don't see any other option.