[英]How I can use a Session for a long time in my ASP.NET Application
I have a ASP.NET Application where I use Sessions. 我有一个ASP.NET应用程序,我使用Sessions。 In this Session I get the language for Example. 在本课程中,我获得了Example的语言。
Example: 例:
Session["language"] = language;
And in a other Area in my Code I use then... 在我的代码中的其他区域,我使用...
language = Session["language"].toString();
It works fine but the user had open the Browser about a feu Hours in the Background with the Application then the Session don't work :( 它工作正常,但用户已打开浏览器关于应用程序背景中的feu小时,然后会话不起作用:(
Why it doesn't work and how I can solve this Problem. 为什么它不起作用以及如何解决这个问题。
我建议你将值保存在cookie中。
You have two options either to use cookies or to increase session timeout setting. 您有两种方法可以使用cookie或增加会话超时设置。
You can increase the session timeout by increasing timeout in the web.config
. 您可以通过增加web.config
中的超时来增加会话超时。
<configuration>
<system.web>
...
<sessionState timeout="90" />
...
</system.web>
</configuration>
In my opinion using cookies is a better approach. 在我看来,使用cookie是一种更好的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.