【发布时间】:2013-11-25 01:44:28
【问题描述】:
我已经实现了自定义 asp.net 身份验证并添加了所有必需的属性,即使用户经常退出。
我在共享的 godaddy 服务器上托管了这个网站。
这是我的代码:
var ticket = new FormsAuthenticationTicket(2, auth.Message.ToString(), DateTime.Now, DateTime.Now.AddDays(3), true,
string.Empty, FormsAuthentication.FormsCookiePath);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket))
{
Domain = FormsAuthentication.CookieDomain,
Expires = DateTime.Now.AddYears(50),
HttpOnly = true,
Secure = FormsAuthentication.RequireSSL,
Path = FormsAuthentication.FormsCookiePath
};
Response.Cookies.Add(cookie);
Response.Redirect(FormsAuthentication.GetRedirectUrl(auth.Message.ToString(), true));
我的 Web.config 具有以下值:
<authentication mode="Forms">
<forms requireSSL="false" timeout="120" loginUrl="~/CRM/Logon.aspx" defaultUrl="~/CRM/OTP.aspx" />
</authentication>
我的用户抱怨他们在 10 到 20 分钟左右就被注销了
感谢任何帮助。
编辑
我已经删除了 requireSSL="false" timeout="120" ,即使这样也没有效果。
我也没有使用会话
【问题讨论】:
-
听起来会话超时导致您的身份验证也超时(或者至少它导致您的用户认为他们已被注销)。 Session timeout defaults to 20 minutes。您的应用是否依赖于 Session 变量?
标签: asp.net forms-authentication