简体   繁体   English

KeepSessionAlive心跳频率

[英]KeepSessionAlive Heartbeat Frequency

I have created a heartbeat mechanism to keep the user's session alive. 我创建了一个心跳机制来使用户会话保持活动状态。 It will run every 60 seconds. 它将每60秒运行一次。 Question is, why not set this to like 15 minutes? 问题是,为什么不将此设置为15分钟? Also, why use a heartbeat at all; 另外,为什么还要使用心跳呢? can't I just set my session expiration time in IIS? 我不能只在IIS中设置会话过期时间吗?

I just want to make it so if a user leaves the page for a half hour or so and goes and gets lunch, that they can come back and their session will still be there when they click submit, so they won't lose any data they might have entered before they left. 我只是想做到这样,如果用户离开页面半小时左右然后去吃午餐,那么他们可以回来并且单击“提交”时会话仍将在那里,因此他们不会丢失任何数据他们可能在离开之前就已经进入了。

$(function () {
    // every 60 seconds...
    setInterval(KeepSessionAlive, 60000);
});

function KeepSessionAlive() {
    $.post("/FACTS/_code/Heartbeat.ashx", null, function () {
        //console.log('Session is alive and kicking');
    });
}   

This can be configured if you are using Session within the .NET framework. 如果您在.NET框架中使用Session,则可以配置它。

A snippet from http://msdn.microsoft.com/en-us/library/h6bb9cz9%28v=vs.100%29.aspx describes how to set a timeout parameter in your web.config if you are using SessionState 来自http://msdn.microsoft.com/zh-cn/library/h6bb9cz9%28v=vs.100%29.aspx的摘录描述了如何在使用SessionState的情况下在web.config中设置超时参数

<configuration>
  <system.web>
    <sessionState 
         mode="[Off|InProc|StateServer|SQLServer|Custom]"
        timeout="number of minutes">
      <providers>...</providers>
    </sessionState>
  </system.web>
</configuration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM