在我的应用程序中,我使用了 Asp.Net 表单身份验证,
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
adminResult.UserName,
DateTime.Now,
DateTime.Now.AddDays(2),
true,
"Administrator",
FormsAuthentication.FormsCookiePath
);
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie coockie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
if (ticket.IsPersistent)
{
coockie.Expires = ticket.Expiration;
}
Response.Cookies.Add(coockie);
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Dashboard", "Cockpit");
}
但它会在 10 到 15 秒内自动注销。
解决方案是什么?
谢谢