AuthenticationService::Login Method
Checks user credentials and creates an authentication ticket (cookie) if the credentials are valid.
Assembly: System.Web.Extensions (in System.Web.Extensions.dll)
[OperationContractAttribute] public: bool Login( String^ username, String^ password, String^ customCredential, bool isPersistent )
Parameters
- username
- Type: System::String
The user name to be validated.
- password
- Type: System::String
The password for the specified user.
- customCredential
- Type: System::String
The value or values to validate in addition to userName and password, if any.
- isPersistent
- Type: System::Boolean
A value that indicates whether the authentication ticket remains valid across sessions.
| Exception | Condition |
|---|---|
| ArgumentNullException | userName or password is nullptr. |
The Login method validates user credentials through a membership provider. You can use the default membership provider or specify a custom membership provider at run time. The AuthenticationService class passes userName and password to the membership provider's ValidateUser method, but does not pass customCredential. If ValidateUser returns true, AuthenticationService creates an authentication ticket as a cookie. Set the isPersistent parameter to true to create an authentication ticket that lasts beyond the current session.
Note: |
|---|
Always use the authentication service together with the secure sockets layer (SSL, by using HTTPS) to protect sensitive data. |
The Login method raises the Authenticating event and the CreatingCookie event. Create an event handler for Authenticating to customize authentication, such as checking the values in customCredential or validating credentials through a non-default membership provider. The values in customCredential are not validated by the default membership provider. To customize the authentication cookie, create an event handler for CreatingCookie.
Note: |
|---|
Do not call the Login method from code that is executing on the Web server. You call the Login method only as part of a WCF service. For more information, see ASP.NET Authentication. |
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: