.NET中的会话无限TimeOut [英] Infinite TimeOut for Session in .NET

查看:101
本文介绍了.NET中的会话无限TimeOut的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个会话[姓名] = Obj.name

如果应用程序闲置了很长时间,我正试图访问会话[名称],

为空。



会话[姓名] = null;



Web.Config

< sessionstate mode =InProccustomprovider =DefaultSessionProvider>



我没有提供任何超时。

可能是默认超时= 20分钟。

我如何提供无限超时。



任何帮助Plz!

解决方案

您当然不希望将超时设置为无限。你将继续堆积资源,服务器最终将翻身并死亡。



我不建议将超时设置得更高。会话计时器每次有回发时重置,因此超时意味着用户在20分钟内没有触摸应用程序。



你可以做几件事执行:



1.

将时间设置为更大的值。您可以在IIS中直接按照应用程序执行此操作,这是一个真正的...导航IIS,因此您需要搜索一下。



2.您可以使用global.asax文件中的事件重置计时器到期时间。



3.您可以通过脚本每xx分钟进行一次回发。



4.(推荐)您可以设置一个脚本计时器,让我们说15分钟并通知用户输入的消息如小心,您的会话即将在5分钟后到期,请执行x或y以继续会话。



我不会这样做1,2或3.



希望这会有所帮助。


在您的Applicaion Web.Config中添加以下配置...



 <   system.web  >  
< sessionState timeout = 30 >
//此处的时间以分钟为单位
< / sessionState >
< / system.web >


Hi,
I have a Session["Name"] = Obj.name
If the App is Idle for a long time , i am trying to access the Session["Name"] ,
its Null.

Session["Name"] = null;

Web.Config
<sessionstate mode="InProc" customprovider="DefaultSessionProvider">

I am not providing any timeout.
May be the default timeout = 20Min.
How can i provide an Infinite Timeout.

Any Help Plz!

解决方案

You certainly don't want to set the timeout to infinite. You'll keep piling up resources and the server will eventually roll over and die.

I would not recommend setting the timeout higher at all. the session timer resets each time there is a postback, so timing out means the user didn't touch the application in over 20 minutes.

There are several things you can do:

1.
set the time out to a larger value. You can do this in IIS directly per application it's a real b... to navigate IIS so you'll need to search a bit.

2. You can reset the timer when it expires by using the events in the global.asax file.

3. You can do a postback via scripting each xx minutes.

4. (recommended) You can set a script timer to let's say 15 minutes and inform the user with a message like "careful, your session is about to expire in 5 minutes, please do x or y to continue the session."

I would not do 1, 2 or 3.

hope this helps.


In Your Applicaion Web.Config add the below Configuration...

<system.web>
    <sessionState timeout="30">
      //here timout is in minutes
    </sessionState>
      </system.web>


这篇关于.NET中的会话无限TimeOut的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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