Easy Tutorial
❮ Razor Cs Variables Prop Webcontrol Panel Direction ❯

WebSecurity - Login()



Definition

The Login() method logs in the specified user using a username and password.


C# and VB Syntax


Examples

Example C

Example VB


Parameters

Parameter Type Description
userName String The username
password String The user's password
persistCookie String true specifies that the authentication token in the cookie should be retained after the current session, otherwise false. The default is false.

Return Value

Type Description
Boolean Returns true if the user is logged in, otherwise false.

Remarks

When a user is logged in, ASP.NET sets an authentication token in the cookie, allowing ASP.NET to know that the user is logged in for subsequent requests. If persistCookie is false, the token is only valid until the user closes the browser.


Errors and Exceptions

Under the following conditions, any access to the WebSecurity object will throw an InvalidOperationException:


Technical Data

Name Value
Namespace WebMatrix.WebData
Assembly WebMatrix.WebData.dll

❮ Razor Cs Variables Prop Webcontrol Panel Direction ❯