나는 내 테스트에서 Form Authentication
을 사용하고있었습니다. 또한 테스트 사용자 이름이 있습니다. 그러나 지정된 이름에 대해 이상한 문제가 발견되었습니다. 그것은 테스트에서 작동 할 수있는 amybeyond
이라는 하나만 제외하고는 모든 테스트 이름입니다.FormsAuthentication.SetAuthCookie가 IE에서 작동하지 않는 이유
내 테스트에서 제 코드를 검토하는 것을 돕습니다.
LoginTest.aspx
(이 사용자 이름과 암호를 입력하는 로그인 폼이다.)public partial class LoginTest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
//after succeed validating user. then redirect to LoginSuccess.aspx page.
bool bValidate=Membership.ValidateUser("amybeyond", "11111111");
if (bValidate)
{
FormsAuthentication.SetAuthCookie("AmyBeyond", false);
Response.Redirect("LoginSuccess.aspx");
}
}
}
LoginSuccess.aspx
(이 페이지에서 단지 테스트 전류 요청 재전송 이후 인증되면 .)public partial class LoginSuccess : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//the HttpContext.Current.Request.IsAuthenticated always false in the IE.
if (HttpContext.Current.Request.IsAuthenticated)
{
Response.Write("ok, you login successfully.");
}
}
}
나는 Membership.ValidateUser
이 성공적으로 실행하고 return true
됩니다 확신합니다. 문제는 성공적으로 리디렉션 한 후 인증 된 상태를 알 수 없다는 것입니다.
내가 뭔가를 놓치거나 잘못한 것을 알지 못했습니다. 있다면. 제발 말해주세요. 감사합니다.
은 추가는
나는 FormsAuthentication.SetAuthCookie
의 소스 코드를 읽어 보시기 바랍니다. Web.config
의 Forms
요소에 cookieless="UseCookies"
을 추가하십시오. 쿠키가 Response
에 추가되었는지 확인하십시오 (소스 코드 HttpContext.Current.Response.Cookies.Add(cookie)
로 완료). 아직도 작동하지 않습니다.
public static void SetAuthCookie(string userName, bool createPersistentCookie, string strCookiePath)
{
Initialize();
HttpContext current = HttpContext.Current;
if (!current.Request.IsSecureConnection && RequireSSL)
{
throw new HttpException(SR.GetString("Connection_not_secure_creating_secure_cookie"));
}
bool flag = CookielessHelperClass.UseCookieless(current, false, CookieMode);
HttpCookie cookie = GetAuthCookie(userName, createPersistentCookie, flag ? "/" : strCookiePath, !flag);
if (!flag)
{
HttpContext.Current.Response.Cookies.Add(cookie);
current.CookielessHelper.SetCookieValue('F', null);
}
else
{
current.CookielessHelper.SetCookieValue('F', cookie.Value);
}
}
라이트
는 HTTP 포착 상세히 아래에 나타낸다. LoginTest.aspx
에는 으로 리디렉션 된 후 FwLoginCookie
이라는 쿠키가 있습니다.이 쿠키는 손실됩니다. 그것을 검토해주십시오.
단일 사용자의 경우? 쿠키가 사용 중지 된 것처럼 들리는데 ... –
예. 단일 사용자 용입니다. IE의 IE 개발자 도구로 세부 사항을 검사 할 때 리디렉션 페이지 (LoginSuccess.aspx)에 성공적으로 인증 된 쿠키가 존재하지 않습니다. 감사. –
그리고 나를 혼란스럽게 만드는 것은 다른 사용자 이름에이 문제가 없다는 것입니다! : P –