意外的会话超时 [英] Unexpected session Timeout

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

问题描述

我有一个托管的.net应用程序。在当地我没有任何问题。但是在线托管网站在5分钟后会有超时会话。我检查了整个网站。但没有其他地方没有它。如何解决此问题?

解决方案

默认情况下,会话超时设置为在ASP.NET中过期在20分钟内。

增加超时或到期,您应该在 web.config中更改 SessionState 的超时属性文件

< sessionState timeout =   40 /> 



请注意,如果您使用的是表单身份验证,则表单超时设置将在设置的超时期限后将用户注销,以便您还必须调整此属性:

 <  身份验证    mode   = 表单 >  
< 表格 timeout = 40 / >
< / authentication >



会话超时后将用户重定向到登录页面类似于在某些间隔方法后刷新页面。唯一不同的是计算页面必须重定向的时间。因此,可以使用Session.timeout属性计算时间,该属性将为该会话提供会话超时值。为该值添加一些优雅时间并自动将用户重定向到登录页面。



使用Window.setTimeout方法

在页面中加载事件:

 body.Attributes.Add(  onLoad  window.setTimeout(   window.location.href ='login.aspx'  &(Session.Timeout *  60  *  1000 )+  10000 &  );





使用元标记 - 刷新

 Response.AppendHeader(  Refresh,Convert.ToString( (Session.T imeout *  60 )+  10 )&  ; URL = Login.aspx



这两种方法都会在会话超时+ 10秒后将用户重定向到登录页面。这是如何在会话超时之后将用户重定向到登录页面而无需用户交互。



另请参阅一些CP文章了解更多详情:

ASP.NET中的会话管理选项 [ ^ ]

ASP.NET中的会话管理 [ ^ ]



要在 IIS 上配置会话超时,请参阅Kishore Sharma在解决方案1中提供的主题。


如果您已检查应用程序中的所有内容并且没有你在哪里设置会话

然后你需要检查sessio的IIS设置n out。

点击这里

IIS中的会话输出设置


下面的线程讨论了类似类型的问题。

如何在asp 2.0中增加12小时的会话时间 [ ^ ]



除此之外你会得到一些关于以下链接的会话超时的良好信息。

为什么Session.Timeout不适用于您的网站 [ ^ ]

会话超时无法正常工作 [ ^

I've a .net application which is hosted. Locally i dont have any issues. But in online hosted website is getting timeout session after 5 mins. I checked the whole website. But no where else its not available. How can i resolve this issue?

解决方案

By default, Session timeouts are set to expire in ASP.NET in 20 minutes.
To increase the timeout or expiry you should change the timeout attribute for SessionState in the web.config file

<sessionState  timeout="40" />


Note that if you are using Forms authentication, the Forms timeout setting will log the user out after the set timeout period so you will also have to adjust this attribute:

<authentication mode="Forms">
          <forms timeout="40"/>
    </authentication>


Redirecting user to login page after session timeout is similar to refreshing the page after certain intervals method. Only thing which will differ is that calculating time after which the page has to be redirected. Hence time can be calculated using Session.timeout property which will give us session timeout value for that session. Add some grace timings to that value and redirect the user to the login page automatically.

Using Window.setTimeout method
In the page Load event:

body.Attributes.Add("onLoad", "window.setTimeout(""window.location.href='login.aspx'""," & (Session.Timeout * 60 * 1000) + 10000 & ");")



Using Meta Tag - Refresh

Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60) + 10) & "; URL=Login.aspx")


Both these methods will redirect the user to login page after session timeout + 10 seconds. This is how you can redirect the user to login page after session timeout without user interaction.

Also refer some CP articles for more details:
Session management options in ASP.NET[^]
Session Management in ASP.NET[^]

To configure Session Time Out on IIS refer the thread provided by Kishore Sharma in Solution 1.


If you have checked everything in your application and no where you are setting session out
then you need to check with IIS setting for session out.
Check here
Session out setting in IIS


Similar type of problem is discussed on below thread.
how can i increase Session time out for 12 hour in asp 2.0[^]

Apart from that you will get some good information about session timeout on below links.
Why Session.Timeout is not working for your website[^]
Session timeout not working properly[^]


这篇关于意外的会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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