【发布时间】:2017-06-11 07:31:11
【问题描述】:
我有 https 网站,并且我使用会员身份登录和 我在控制器中的代码:
int timeout = rememberme ? 2880 : 2; // Timeout in minutes,525600 = 365 days
var ticket = new FormsAuthenticationTicket(username, rememberme, timeout);
string encrypted = FormsAuthentication.Encrypt(ticket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
cookie.Expires = DateTime.Now.AddMinutes(timeout);//My Line
Response.Cookies.Add(cookie);
string returnurl = FormsAuthentication.GetRedirectUrl(username, rememberme);
if (string.IsNullOrEmpty(returnurl)) returnurl = "/Panel/Login";
if (string.IsNullOrEmpty(returnurl)) returnurl = "/Panel/Login";
if (rol == "User")
return Redirect("/Panel/Dashboard");
else if (rol == "Admin")
return Redirect("/Panel/DashboardAdmin");
return View();
在 we.config 中:
<httpRuntime targetFramework="4.6.2" executionTimeout="100000000" maxRequestLength="2147483647" />
<authentication mode="Forms">
<forms loginUrl="~/Panel/Login" requireSSL="true" slidingExpiration="true" />
</authentication>
<httpCookies httpOnlyCookies="true" requireSSL="true" />
所以它只需保持登录 2 分钟并记住我不工作 我该怎么办?
【问题讨论】:
-
我认为这与 SSL 无关。
-
\你的问题是超时卡在2吗?
-
感谢您的回答,我不知道它的 2 分钟或者它只是不工作,并且在短时间内它会退出(我不知道它是 2 分钟或更长时间)
-
我认为它是 ssl,因为我有另一个带有 http 且工作正常的网站
-
你使用 IIS 吗? cookie 可能会在应用程序池回收后失效,通常在 20 分钟左右或重新启动应用程序时。
标签: c# asp.net-mvc https asp.net-membership