2012-11-28 5 views
0

나는 다음과 Web.config를 가지고 cookiename :Web.config의 폼 인증은

<system.web> 
<customErrors mode="Off"/> 

<authentication mode="Forms"> 
    <forms loginUrl="Login.aspx" name="SIPE_ASPXAUTH"> 
    <credentials passwordFormat="Clear"> 
     <user name="user1" password="123456"/> 
     <user name="user2" password="123456"/> 
     <user name="user3" password="123456"/> 
    </credentials> 

    </forms> 

</authentication> 


<authorization> 

    <deny users="?"/> 
</authorization> 
<compilation debug="true"/> 

이 Web.config를 항상 나를는 다음 URL

http://localhost:53077/Login.aspx?ReturnUrl=%2fDefault.aspx 

로 리디렉션 내 시작 페이지는 Login.aspx이며 올바른 크레디트 텐트를 입력 한 후에도 위 URL로 리디렉션됩니다.

그래서 여기까지했습니다. 나는

<forms loginUrl="Login.aspx"> 

에서 이름 속성을 꺼내 그대로 다른 모든 떠났다. 완벽하게 작동합니다.

누구에게 설명 할 수 있습니까? 본인은 cookiename이며 기본값은 ASPXAUTH임을 이해합니다. 이 쿠키는 사용자를 인증하는 데 사용됩니다. 또한 도구에 저장됩니다. 선택 사항 ...

이 쿠키 이름을 설정하는 용도는 무엇입니까? 그것이 내가이가 <forms loginUrl="Login.aspx">

에 이름을 갖는으로 작업 할 수 확인 것 같다

답변

0

구성 설정은 U 감사하지만 당신은 몇 가지 코드를 작성했을 어떻게 functinality.n 크로스 브라우저를 허용하는 것입니다 로그인 페이지의 코드는 양식 인증에도 사용됩니다. 사용자 이름을 확인한 후 & 암호 corrent 당신이 코드 아래에 작성해야 할 것입니다 : 폼 인증에 대한 세부 내용은

FormsAuthentication.SetAuthCookie(
       this.TextBox_username.Text.Trim(), flase); 

     FormsAuthenticationTicket ticket1 = 
      new FormsAuthenticationTicket(
       1,         // version 
       this.TextBox_username.Text.Trim(), // get username from the form 
       DateTime.Now,      // issue time is now 
       DateTime.Now.AddMinutes(10),   // expires in 10 minutes 
       false,  // cookie is not persistent 
       "HR"        // role assignment is stored 
       // in userData 
       ); 
      HttpCookie cookie1 = new HttpCookie(
      FormsAuthentication.FormsCookieName, 
      FormsAuthentication.Encrypt(ticket1)); 
      Response.Cookies.Add(cookie1); 

Click Here