【问题标题】:ASP.NET authenticated users signout frequently even after applying all attributes即使在应用所有属性后,经过 ASP.NET 身份验证的用户也经常注销
【发布时间】: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


【解决方案1】:

问题是我们还需要指定应用程序池空闲超时以使上述条件有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-31
    • 2020-11-15
    • 2016-01-17
    • 1970-01-01
    • 2020-08-16
    • 2015-03-19
    • 1970-01-01
    相关资源
    最近更新 更多