AuthenticatingEventArgs 类


Authenticating 事件提供数据。Provides data for the Authenticating event.

public ref class AuthenticatingEventArgs : EventArgs
public class AuthenticatingEventArgs : EventArgs
type AuthenticatingEventArgs = class
    inherit EventArgs
Public Class AuthenticatingEventArgs
Inherits EventArgs


下面的示例演示了一个事件处理程序, UserNamePassword处理程序将和值传递到自定义成员资格提供程序来验证用户凭据。The following example shows an event handler that passes the UserName and Password values to a custom membership provider to validate the user credentials. 事件处理程序将Authenticated设置为ValidateUser方法的返回值, 并AuthenticationServiceAuthenticationIsComplete设置true为, 以使类不验证凭据。The event handler sets Authenticated to the return value of the ValidateUser method and sets AuthenticationIsComplete to true so that the AuthenticationService class does not validate the credentials.

void AuthenticationService_Authenticating(object sender, System.Web.ApplicationServices.AuthenticatingEventArgs e)
    if (e.UserName.IndexOf("") >= 0)
        e.Authenticated = Membership.Providers["ContosoSqlProvider"].ValidateUser(e.UserName, e.Password);
    else if (e.UserName.IndexOf("") >= 0)
        e.Authenticated = Membership.Providers["FabrikamSqlProvider"].ValidateUser(e.UserName, e.Password);
        e.Authenticated = Membership.Provider.ValidateUser(e.UserName, e.Password);
    e.AuthenticationIsComplete = true;
Sub AuthenticationService_Authenticating _
   (ByVal sender As Object, _
    ByVal e As System.Web.ApplicationServices.AuthenticatingEventArgs)
    If (e.Username.IndexOf("") >= 0) Then
        e.Authenticated = Membership.Providers("ContosoSqlProvider").ValidateUser(e.Username, e.Password)
    ElseIf (e.Username.IndexOf("") >= 0) Then
        e.Authenticated = Membership.Providers("FabrikamSqlProvider").ValidateUser(e.Username, e.Password)
        e.Authenticated = Membership.Provider.ValidateUser(e.Username, e.Password)
    End If
    e.AuthenticationIsComplete = True
End Sub


如果要自定义在运行Authenticating时对用户凭据进行身份验证的方式, 则可以为事件创建处理程序。You create a handler for the Authenticating event when you want to customize how the user's credentials are authenticated at run time. 类将值提供给任何Authenticating事件处理程序。 AuthenticatingEventArgsThe AuthenticatingEventArgs class supplies values to any Authenticating event handler. 通过使用此类中提供的属性, 你可以检索用户凭据以自定义身份验证。By using the properties available in this class, you can retrieve the user credentials to customize authentication.

类在验证用户Authenticating凭据前引发事件。 AuthenticationServiceThe AuthenticationService class raises the Authenticating event before validating the user credentials. 类构造AuthenticatingEventArgs对象的实例并将其传递给任何Authenticating事件处理程序。 AuthenticationServiceThe AuthenticationService class constructs an instance of the AuthenticatingEventArgs object and passes it to any Authenticating event handler.

您可以使用UserNamePasswordCustomCredential属性来检索用户凭据。You can use the UserName, Password and CustomCredential properties to retrieve the user credentials. CustomCredential属性可以包含身份验证所需的其他值, 如标识号。The CustomCredential property can contain additional values that are required for authentication, such as an identification number.

Authenticated属性指示用户凭据是否有效。The Authenticated property indicates whether the user credentials are valid. Authenticated属性设置为自定义身份验证的结果。You set the Authenticated property to the result of your customized authentication. 此外, 如果已检查用户AuthenticationIsComplete凭据AuthenticationService , true并且不希望类通过默认的成员资格提供程序检查用户凭据, 则将属性设置为。In addition, you set the AuthenticationIsComplete property to true if you have checked the user credentials and do not want the AuthenticationService class to check user credentials through the default membership provider.



获取或设置一个值,该值指示用户凭据是否有效。Gets or sets a value that indicates whether the user credentials are valid.


获取或设置一个值,该值指示用户凭据是否已经过身份验证。Gets or sets a value that indicates whether the user credentials have been authenticated.


获取用于身份验证的其他用户值。Gets additional user values for authentication.


获取用户的密码。Gets the password for the user.


为用户获取身份验证名称。Gets the authentication name for the user.



确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)