首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FormsAuthentication超时问题

FormsAuthentication超时问题
EN

Stack Overflow用户
提问于 2011-08-16 23:09:41
回答 1查看 462关注 0票数 0
代码语言:javascript
复制
protected void Page_Load(object sender, EventArgs e)
        {
            if (HttpContext.Current.User.Identity.IsAuthenticated)
            {
                Session["User"] = "Authenticated";
                Session["Username"] = HttpContext.Current.User.Identity.Name;
                Response.Redirect("HomePage.aspx");
            }

        }

protected void btnSubmit_Click(object sender, EventArgs e)
        {
           int recordExistCount = fc.Authenticate(txtUsername.Text.Trim(), txtPassword.Text.Trim());
           if (recordExistCount == 1)
           {
               Session["User"] = "Authenticated";
               Session["Username"] = txtUsername.Text.Trim();
               fc.IsOnlineRecord(Session["Username"].ToString(),true);
               var ticket = new FormsAuthenticationTicket(2,Session["username"].ToString(),DateTime.Now,DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), true,"",FormsAuthentication.FormsCookiePath);
               var encryptedTicket = FormsAuthentication.Encrypt(ticket);
               var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket)
               {
                   HttpOnly = FormsAuthentication.RequireSSL,
                   Path = FormsAuthentication.FormsCookiePath,
                   Domain = FormsAuthentication.CookieDomain
               };
               Response.Cookies.Add(cookie);
               Response.Redirect("HomePage.aspx");  
           }

 <authentication mode="Forms">
        <forms loginUrl="LoginPage.aspx"
           protection="All"
           timeout="60"
           name=".ASPXAUTH"
           path="/"
           requireSSL="false"
           slidingExpiration="true"
           defaultUrl="HomePage.aspx"
           cookieless="UseDeviceProfile"
           enableCrossAppRedirects="false"/>
      </authentication>

我的页面在闲置超过10分钟后就会超时。我想知道出了什么问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-16 23:13:20

可能是你的会话超时了,而不是表单。您是否在Web.Config中设置了会话超时时间?这可以在sessionState元素(在system.web元素内)中完成

有关更多信息,请查看此链接:http://msdn.microsoft.com/en-us/library/h6bb9cz9%28v=VS.100%29.aspx

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7080494

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档