为什么会话在IIS中给定时间之前很快到期 - Visual Studio 2012 [英] Why session expire very quickly before given time in IIS - Visual Studio 2012

查看:109
本文介绍了为什么会话在IIS中给定时间之前很快到期 - Visual Studio 2012的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了问题,

我在web.config中设置了会话时间



I have facing a problem,
I have set session time out in web.config

<system.web>
      <sessionState timeout="60" mode="InProc" />
    <httpRuntime targetFramework="4.5" />
    <compilation debug="true" targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
  </system.web>







在我的控制器中






In my controller

public ActionResult CreateBrand()
        {
            Session.Timeout=60;
            Purchase purchase = Session["purchaseItem"] as Purchase;
            if (purchase!=null && purchase.Brand != null)
            {
                return View(purchase.Brand);
            }
            return View();
        }







任何博德都可以告诉我会话有什么问题。为什么会话过期很快,可能只在1或2分钟内?




Any bode can tell me what is the problem with session. Why session expire very quickly, may be within just 1 i or 2 minutes?

推荐答案

你绝对需要使用InProc吗?我建议您使用(a)会话状态服务器或(b)SQL Server来管理您的用户会话。我没有让一个客户抱怨他们的会话在离开他们的计算机10-20分钟后到期,我们正在使用SQL Server来管理用户会话。基于SQL Server的会话也可以在应用程序池中循环使用。



或者,如果你绝对必须使用InProc,那么你可以尝试两种不同的东西:(a)确保你的应用程序池的超时设置正确,并且(b)实现类似IFRAME的东西,每隔几秒或几分钟自动刷新用户会话(保持活跃)。



首先,尝试IIS方法:

- 打开IIS

- 选择左侧的应用程序池

- 选择使用的应用程序池您的网站

- 选择高级设置

- 在Process Model categories下,将'Idle Time-out'值增加到所需的长度。



其次,尝试在Google上搜索ASP.NET Keep Alive示例。希望这些信息有用!
Do you absolutely need to use InProc? I suggest you either use (a) Session State Server or (b) SQL Server to manage your user sessions. I have not had one client complain about their session expiring after leaving their computer for 10-20 minutes, and we are using SQL Server to manage the user sessions. SQL Server-based sessions also survives application pool recycles.

Alternatively, and if you absolutely MUST use InProc, then you can try two different things: (a) Ensure your application pools' timeout is set correctly, and (b) implement something like an IFRAME that refreshes the user session automatically every few seconds or minutes ("Keep Alive").

First, try the IIS method:
- Open IIS
- Select Application Pools on the left side
- Select the Application Pool used by your site
- Choose advanced settings
- Under Process Model categtory increase the 'Idle Time-out' value to the desired length.

Second, try searching Google for an ASP.NET Keep Alive example. Hope this info helps!


这篇关于为什么会话在IIS中给定时间之前很快到期 - Visual Studio 2012的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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