如果用户的密码有效,我正在使用此功能重定向我的用户:
if (ValidateUser(txtUsername.Text, txtPassword.Text))
{
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, txtUsername.Text, DateTime.Now,
DateTime.Now.AddHours(12), chkPersistCookie.Checked, "your custom data");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
ck.Expires = tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
string strRedirect;
strRedirect = Request["ReturnUrl"];
if (strRedirect == null)
strRedirect = "default.aspx";
Response.Redirect(strRedirect, true);
}
else
lblStatus.Text = "Incorrect Username or Password, please try again.";
它在我测试过的每个平台上的每个浏览器上都能正常工作,除了Surface平板电脑上的IE浏览器。通过Metro应用程序或桌面版本。它只是重新加载回原始的空白登录屏幕。有人有这个问题吗?