AuthenticationService.Authenticating Evento
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
Si verifica quando le credenziali utente vengono convalidate.
public:
static event EventHandler<System::Web::ApplicationServices::AuthenticatingEventArgs ^> ^ Authenticating;
public static event EventHandler<System.Web.ApplicationServices.AuthenticatingEventArgs> Authenticating;
member this.Authenticating : EventHandler<System.Web.ApplicationServices.AuthenticatingEventArgs>
Public Shared Custom Event Authenticating As EventHandler(Of AuthenticatingEventArgs)
Tipo evento
Esempio
Nell'esempio seguente viene illustrato come associare un gestore eventi per l'evento Authenticating nel Application_Start
metodo del file Global.asax.
void Application_Start(object sender, EventArgs e)
{
System.Web.ApplicationServices.AuthenticationService.Authenticating +=
new EventHandler<System.Web.ApplicationServices.AuthenticatingEventArgs>(AuthenticationService_Authenticating);
}
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
AddHandler System.Web.ApplicationServices.AuthenticationService.Authenticating, _
AddressOf Me.AuthenticationService_Authenticating
End Sub
Nell'esempio seguente viene illustrato un gestore eventi per l'evento Authenticating nel file Global.asax. Il gestore eventi legge due valori di autenticazione dalla CustomCredential proprietà e li passa insieme al nome utente e alla password a una classe di autenticazione personalizzata denominata StudentAuthentication
.
void AuthenticationService_Authenticating(object sender, System.Web.ApplicationServices.AuthenticatingEventArgs e)
{
string studentid = String.Empty;
string answer = String.Empty;
string[] credentials =
e.CustomCredential.Split(new char[] { ',' });
if (credentials.Length > 0)
{
studentid = credentials[0];
if (credentials.Length > 1)
{
answer = credentials[1];
}
}
try
{
e.Authenticated =
StudentAuthentication.ValidateStudentCredentials
(e.UserName, e.Password, studentid, answer);
}
catch (ArgumentNullException ex)
{
e.Authenticated = false;
}
e.AuthenticationIsComplete = true;
}
Sub AuthenticationService_Authenticating _
(ByVal sender As Object, _
ByVal e As System.Web.ApplicationServices.AuthenticatingEventArgs)
Dim studentid As String = String.Empty
Dim answer As String = String.Empty
Dim credentials As String() = _
e.CustomCredential.Split(New Char() {","c})
If (credentials.Length > 0) Then
studentid = credentials(0)
If (credentials.Length > 1) Then
answer = credentials(1)
End If
End If
Try
e.Authenticated = _
StudentAuthentication.ValidateStudentCredentials _
(e.Username, e.Password, studentid, answer)
Catch ex As ArgumentNullException
e.Authenticated = False
End Try
e.AuthenticationIsComplete = True
End Sub
Commenti
L'evento Authenticating viene generato quando vengono convalidate le credenziali utente. Creare un gestore eventi per l'evento per personalizzare la Authenticating modalità di convalida delle credenziali utente.
Si applica a
Vedi anche
Commenti e suggerimenti
https://aka.ms/ContentUserFeedback.
Presto disponibile: Nel corso del 2024 verranno gradualmente disattivati i problemi di GitHub come meccanismo di feedback per il contenuto e ciò verrà sostituito con un nuovo sistema di feedback. Per altre informazioni, vedereInvia e visualizza il feedback per