C# 如何增加formsauthentication票证的会话持续时间

C# 如何增加formsauthentication票证的会话持续时间,c#,asp.net,asp.net-mvc-4,C#,Asp.net,Asp.net Mvc 4,我的站点存在问题,用户会话在15分钟不活动后被注销 发生这种情况时,如果用户单击任何链接,它会将他们带回登录页面 我想将用户会话注销的持续时间增加到2小时 以下是进行初始身份验证的方法: [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Login(LoginModel model, string returnUrl) {

我的站点存在问题,用户会话在15分钟不活动后被注销

发生这种情况时,如果用户单击任何链接,它会将他们带回登录页面

我想将用户会话注销的持续时间增加到2小时

以下是进行初始身份验证的方法:

[HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            var mcookie = new AbcCookie();

            if (ModelState.IsValid)
            {
                using (var marvRepo = new AbcRepositry())
                {
                    var passwordHash = Abc.Web.Portal.Helpers.Security.CreatePasswordHash(model.Password);

                    var userAccount = marvRepo.GetAbcUser(model.UserName,model.PartnerAccessCode);

                    if(userAccount != null && userAccount.Password == passwordHash && userAccount.PartnerAccessCode == model.PartnerAccessCode.ToUpper())
                    {
                        mcookie.GetMMformsauthentication(userAccount, model.RememberMe);


                           return RedirectToLocal(returnUrl);
                    }
                    else
                    {
                        ModelState.AddModelError("", "The user name,access code or password provided is incorrect.");
                    }


                }

        }
这是表单验证

public void GetMMformsauthentication(UserAccount UserAccount,bool createPersistentCookie) { 常量字符串UnknownUsername=“匿名”

我已经尝试增加身份验证票证的持续时间,但是会话在15分钟后超时,无论使用什么值

我在web.config中添加了以下内容,以查看这是否能解决问题

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>

我假设“超时”值以分钟为单位(我故意将该值设置为一个高值)

我已经尝试了所有方法,但我的会话在15分钟后仍然自动注销


有人知道是什么原因导致登录会话在15分钟后结束吗?

您是否搜索了“IIS会话超时”,但没有发现任何有用的信息?您是否设置了
滑动过期时间
(如果您需要的话)?我没有添加SlidingExpiration,因为这不是我想要的。我希望登录会话在2小时内超时。我还将此添加到我的web.config:
<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>