会话超时没有在asp.net mvc的4 C#的工作。为什么? [英] Session timeout does not work at asp.net mvc 4 C# . Why?

查看:123
本文介绍了会话超时没有在asp.net mvc的4 C#的工作。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的网站我配置的登录会话超时1周在web.config文件

For my web site I configured login session timeout for 1 week in web.config file

<system.web>
  <httpRuntime />

  <!-- Session keeps for 7 days -->
    <sessionState timeout="10080"></sessionState>
    <authentication mode="Forms">
      <forms loginUrl="~/" timeout="10080" slidingExpiration="true"/>
    </authentication>
  <!-- Configuration end  -->
</system.web>

下面是code为登录

    [AllowAnonymous]
    [HttpPost]
    public ActionResult Login(string Login, string Password)
    {
        // empty passwords are not allowed
        if (Password == "")
            return Redirect(Request.UrlReferrer.ToString());

        bool LoginResult = WebSecurity.Login(Login, Password, true);
        return Redirect(Request.UrlReferrer.ToString());
    }

我登录,关闭浏览器,然后打开它再次去我的网站 - >用户登录。
我关闭浏览器,等待一段时间(约30分钟)去我的网站 - >用户注销。
为什么?会话应存放7天,但我们不具有甚至30分钟。
焕可能是问题的根源?

I login, close browser and open it again go to my web site -> user is logged in. I close browser, wait some time (about 30 minutes) go to my web site -> user is logged off. Why? Session should be stored for 7 days but we does not have even 30 minutes. Whan can be the source of problem?

修改1 主要的想法是,我想回去到现场数天,并仍与登录用户打开它

推荐答案

也许,你的 IIS 将被配置到20分钟超时

Possibly, your IIS would have been configured to 20 minutes of TimeOut.

更改 IIS 会话超时1周 24小时,我希望能够解决你的问题。

Change the IIS session timeout to 1 week 24 hours, which I hope will solve your problem.

通过设计,超时的最大值被设定为24小时。查看Microsoft支持论坛

By design, the maximum value of timeout is set to be 24 hours. Check out Microsoft support forum

要实现超时较大的窗口,你可以考虑在 SQL ,由@Marc建议。

To achieve a larger window for timeout, you could consider maintaining session states in SQL, as suggested by @Marc.

这篇关于会话超时没有在asp.net mvc的4 C#的工作。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆