![](/img/trans.png)
[英]Programmatically refreshing session timeout in ASP.NET MVC4 application
[英]How to maintain session timeout for long period in asp.net mvc4?
我对Web.config和globals.asax文件做了一些修改,给出了一些额外的时间限制,但是会话在给定的时间内无法正常工作。 有时很快就会过期。
Web.config文件:
<sessionState mode="InProc" customProvider="DefaultSessionProvider" timeout="60000"/>
<authentication mode="Forms">
<forms loginUrl="~/Home/Login" timeout="28880"/>
</authentication>
Global.asax中/在session_start():
Session.Timeout = 1200;
我在需要的地方为会话添加了名称空间,但是会话问题仍然存在,所有编码完成后,会话是无状态的。
请任何人提出适当的解决方案,或者如果我的流程不明确,请让我知道如何以标准方式进行。
谢谢。 帮助将不胜感激。
您在2个不同的位置提供超时,我的意思是您需要在web.config或global.asax文件中提供超时,以便更好地从global.asax中删除超时声明。
如此处http://www.aspdotnet-suresh.com/2010/10/session-timeout-problem-in-aspnet.html中所提:
默认情况下,我们的网站会话超时是该会话过期后的20分钟,假设如果我们想在应用程序中设置自定义超时,则可以通过不同的方式(web.config,global.asax和IIS)进行设置
检查以下方法以在web.config,global.asax和iis中设置会话超时
在Web.config文件中,我们可以设置会话超时,如下所示
<configuration>
>
> <system.web>
>
> <sessionState mode="InProc" timeout="60">
>
> </sessionState>
>
> </system.web>
>
> </configuration>
在Global.asax文件中,我们可以像这样在Session_Start事件中设置会话超时
void Session_Start(object sender, EventArgs e)
>
> {
>
> // Code that runs when a new session is started
>
> Session.Timeout = 15;
>
> }
如果在web.config和iis中都设置了会话超时,则iis会话超时值将覆盖web.config会话超时
如果上述解决方案不起作用,则删除
<authentication mode="Forms">
<forms timeout="50"/>
从web.config文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.