票据无法读取,求教
我一开始数据库用的access。。完全没问题,后来数据库改为了sqlserver。。。就出问题了(ie cookies已经清空)
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
TextBox1.Text, // Username associated with ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes(100), // Date/time to expire
true, // "true" for a persistent user cookie
js, // User-data, in this case the roles
FormsAuthentication.FormsCookiePath);// Path cookie valid for
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName, // Name of auth cookie
hash); // Hashed ticket
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
Response.Cookies.Add(cookie);
Response.Redirect("jump.aspx");
然后读取票据的时候
FormsIdentity f1 = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket t1 = f1.Ticket;
string user = t1.Name;
string js = t1.UserData;
放在登陆页面能取出内容
放在其他页面读取出来就是空。。
求教!!!