Login::OnLoggingIn Method (LoginCancelEventArgs^)
Raises the LoggingIn event when a user submits login information but before the authentication takes place.
Assembly: System.Web (in System.Web.dll)
Parameters
- e
-
Type:
System.Web.UI.WebControls::LoginCancelEventArgs^
A LoginCancelEventArgs containing the event data.
The OnLoggingIn method raises the LoggingIn event. Use the LoggingIn event to perform any processing that you need before authenticating a user or to perform custom validation.
Raising an event invokes the event handler through a delegate. For more information, see Handling and Raising Events.
The OnLoggingIn method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.
Notes to Inheritors:
When overriding OnLoggingIn in a derived class, be sure to call the base class's OnLoggingIn method so that registered delegates receive the event.
The following code example uses the LoggingIn event to ensure that the user has entered a well-formed e-mail address in the UserName property. If not, the LoggingIn event handler cancels the login attempt and displays the error message specified in the InstructionText property.
The following code example demonstrates how you can extend the Login control. The CustomLogin control includes a DropDownList control that lets users choose which membership provider they are authenticated with. (These providers are configured in Web.config.) In the OnLoggingIn method, the MembershipProvider property is set to the selected value of the DropDownList control.
Security Note
|
|---|
This example contains a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
Available since 2.0
