如何在asp.net中增加会话超时? [英] how to increase session timeout in asp.net?

查看:95
本文介绍了如何在asp.net中增加会话超时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用以下代码来增加会话超时,但是没有用,

I tried following codes to increase session timeout, but no use,

代码是:

<sessionState mode="InProc" cookieless="true" timeout="60">
</sessionState>

也位于

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
Session.Timeout = 15;
}

推荐答案

您可以通过以下任意一种方式增加asp.net中的会话超时时间

You can increase the session time-out in asp.net in any one of the following ways

使用IIS版本7:

  1. 打开 IIS
  2. 从网站列表中选择您的网站
  3. 单击右侧的会话状态
  4. 现在在cookie设置下输入您的会话超时
  1. Open up IIS
  2. Select your website from the list of sites
  3. Click on Session state on the right
  4. Now enter your session timeout under the cookie settings

OR

Web.config: 打开您的web.config文件,并在 system.web 部分下添加以下内容:

Web.config : Open up your web.config file and under the system.web section add the following :

<sessionState timeout = "20" mode = "InProc" />

将20替换为您想要的任何数字.

Replace 20 with whatever number you wish.

OR

Global.asax文件: Session_Start 方法下,将会话的 timeout 属性设置为所需的值,例如

Global.asax file : Under the Session_Start method, set the timeout property of the session to the required value like this

Session.Timeout = "20";

注意::如果您要同时在IIS和web.config中设置会话超时,则IIS中的会话超时将覆盖web.config中的会话超时

Note : If you are setting a session timeout in both IIS as well as web.config, then the one in IIS will override the one in web.config

希望这会有所帮助!

这篇关于如何在asp.net中增加会话超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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