Export (0) Print
Expand All

Login::OnLoggingIn Method

Raises the LoggingIn event when a user submits login information but before the authentication takes place.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

protected:
virtual void OnLoggingIn(
	LoginCancelEventArgs^ e
)

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.

No code example is currently available or this language may not be supported.

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 noteSecurity 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.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft