WebSecurity - 로그인()
❮ 웹보안
정의
Login() 메서드 는 사용자 이름과 암호를 사용하여 지정된 사용자에 로그인합니다.
C# 및 VB 구문
WebSecurity.Login(userName,
password, persistCookie)
예
예 C#
if (WebSecurity.Login(username,password))
{
<p>Welcome</p>
}
else
{
<p>Incorrect username or password.</p>
}
예제 VB
if WebSecurity.Login(username,password)
<p>Welcome</p>
else
<p>Incorrect username or password</p>
end if
매개변수
Parameter | Type | Description |
---|---|---|
userName | String | The user name |
password | String | The user password |
persistCookie | String | true to specify that the authentication token in the cookie should be persisted beyond the current session; otherwise false. Default is false. |
반환 값
Type | Description |
---|---|
Boolean | true if the user is logged in, otherwise false |
비고
사용자가 로그인하면 ASP.NET은 이후 요청에서 사용자가 로그인했음을 ASP.NET이 알 수 있도록 쿠키에 인증 토큰을 설정합니다 .persistCookie 가 false이면 토큰은 사용자가 브라우저를 닫을 때까지만 유효합니다. .
오류 및 예외
WebSecurity 개체 에 대한 모든 액세스는 다음과 같은 경우 InvalidOperationException 을 발생시킵니다 .
- InitializeDatabaseConnection() 메서드가 호출되지 않았습니다 .
- SimpleMembership 이 초기화되지 않았습니다(또는 웹사이트 구성에서 비활성화됨).
❮ 웹보안