17.7 | 코드 기반으로 인증과 권한 처리하기

     

    ASP.NET에서 기본적으로 제공하는 로그인 컨트롤을 사용하지 않고 인증과 권한 기능을 구현하고자 할 때는 다음 네 가지 명령어를 기억하면 된다.

    로그인 처리

    - System.Web.Security.FormsAuthentication.SetAuthCookie()

    - System.Web.Security.FormsAuthentication.RedirectFromLoginPage()

    로그인 확인

    - User.Identity.IsAuthenticated

    로그인 이름

    - User.Identity.Name

    로그아웃

    - FormsAuthendtication.Signout()

     

    이 네 명령어는 반드시 Web.config 파일의 인증 모드가 다음과 같이 Forms로 되어 있어야 한다.


    <authentication mode=“Forms” />
    

    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.