我正在尝试从身份验证票中读取用户名(即TESTTEST
)
-----登录页面-----
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
"TESTTEST",
DateTime.Now,
DateTime.Now.AddMinutes(30),
false,
String.Empty,
FormsAuthentication.FormsCookiePath);
string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie authCookie = new HttpCookie(
FormsAuthentication.FormsCookieName,
encryptedTicket);
authCookie.Secure = true;
Response.Cookies.Add(authCookie);
FormsAuthentication.RedirectFromLoginPage("User", false);
------受保护的页面-----
HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);
Label1.Text = ticket.Name;
结果:标签文本"USER"
代替"TESTTEST"
我能做些什么来解决这个问题并获得正确的值?