2

좋아, 그래서 MVC4 응용 프로그램과 함께 사용하기 위해 사용자 정의 ExtendedMembershipProvider를 구현했습니다.이 모든 것은 유선이지만 제대로 작동하지만 폼 인증 쿠키에 문제가 있습니다.ExtendedMembershipProvider 및 WebSecutiry.Login, persistCookie는 어디에 있습니까?

직접 로그인 프로세스를 호출 할 때 내 자신의 쿠키를 만들지 만 WebSecurity.Login 기능을 사용하면 쿠키를 직접 제어 할 수 없습니다.

public static bool Login(
    string userName, 
    string password, 
    bool persistCookie (optional) 
) 

이제이 기능은 두 개의 매개 변수를 취하는 ExtendedMembershipProvider에 ValidateUser 함수를 호출 :

그래서 내 질문에 날 리드는 WebSecurity.Login은 (선택 사항 중 하나) 세 ​​가지 매개 변수를

public abstract bool ValidateUser(
    string username, 
    string password 
) 

persistCookie 매개 변수는 어디에 있습니까? WebSecurity.Login이 쿠키 생성 자체를 처리합니까? 그렇다면 어떻게 재정의 할 수 있습니까?

도움이 많이 되셨습니다.

답변

0

WebSecurity.Login은 아마 다음과 같은 코드를 실행합니다 :

static bool Login(string userName, string password, bool persistCookie) 
{ 
    if(System.Web.Security.Membership.Provider.ValidateUser(userName, password)) 
    { 
     System.Web.Security.FormsAuthentication.SetAuthCookie(userName, persistCookie); 
     return true; 
    } 

    return false; 
} 

당신이 동작을 변경 answer를 다음의 지침에 따라이 조각을 변경하려면

.