我用的是Forms身份认证,过期时间为60分钟,可总是不到时间,有时20多分钟,有时40多分钟,就到期,身份信息丢失.可是却可以读到保存票证的cookie,看来客户端是正常的,是服务端出了问题,但是问题出在哪儿呢?是服务端不再读cookie中的票证,还是该票证已经过期,还是我的代码有问题?(用的是万网的asp.net虚拟主机,在本地调试没有这种问题)代码如下:
FormsAuthenticationTicket userTicket;
HttpCookie    userCookie;
string    secTicket;userTicket=new FormsAuthenticationTicket(1,userName,DateTime.Now,DateTime.Now.AddMinutes(60),false,userRole);secTicket=FormsAuthentication.Encrypt(userTicket);
userCookie=new HttpCookie(FormsAuthentication.FormsCookieName,secTicket);Response.Cookies.Add(userCookie);

解决方案 »

  1.   

    maybe because of session.
    session depend on computer memory, if there is no enough memory, then asp.net will clear session to release memory.
    do not put too many object in session.
      

  2.   

    二楼的兄弟,谢谢您的回复。但是我的forms票证是保存在cookie里的,并没有用session呀。
    而且还能在cookie里读出此票证,但是服务端,已经在过期之前不再认可此票证。
    这是为什么呢?