如何在global.asax中使用会话超时
问题描述:
嗨....朋友
-i想给会话时间30分钟,以便在任何用户和管理员登录时都有效,然后在30分钟后他的会话将过期,需要重新登录,所以我该如何在global.asax中实现此任务?
-i这里关于Session_Start来执行此任务的方法正确吗????
hi....friends
-i want to give session time 30 minites so in any user and admin login and then after 30 minites his session is expire and need to relogin so how can i implement this task in global.asax
-i here about Session_Start to perform this task is it right way?????
答
您可以使用Web.Config文件来完成.有以下三种会话类型,您必须将以下部分添加到web.config
1)InProc
you can do using Web.Config file. there are three type of Session as below, you have to add below section into web.config
1)InProc
<sessionstate mode="InProc" cookieless="true" timeout="30" />
2)StateServer
2)StateServer
<sessionstate mode="StateServer" stateconnectionstring="tcpip=SampleStateServer:42424" cookieless="false" timeout="30" />
3)SQLServer
3)SQLServer
<sessionstate mode="SQLServer" sqlconnectionstring="Integrated Security=SSPI;data source=SampleSqlServer;" />
用户闲置30分钟后,会话将自动过期
session will expire automatically when user is idle for 30 min
在Web配置中尝试以下操作:
Try this one in web config:
<system.web>
<sessionState timeout="60" />
</system.web>