2011-07-17 72 views
2

如何防止Session.Timeout在代码隐藏的某些事件上扩展?阻止Session.Timeout扩展

<asp:Timer ID="Timer7" runat="server" Interval="540000" ontick="Timer7_Tick"> 
       </asp:Timer> 

protected void Timer7_Tick(object sender, EventArgs e) 
     { 
      showModalPopupServerOperatorButton_Click(null, null); 
      Timer7.Enabled = false; 
} 

初步计算是在会话结束前1分钟,我会通知用户的东西与ModalPopup。问题是,当这个Timer7_Tick事件触发时,Session.Timeout更新和会话10分钟后结束(如果用户仍然不从他的浏览器发送任何请求)。

回答

1

服务器端执行会延长会话超时。如果您只想弹出一个对话框,请尝试使用JavaScript,而不进行任何回传。

15+ jQuery Popup Modal Dialog Plugins and Tutorials.

使用Timer control的一种替代,使用这个JavaScript:

<script type="text/javascript">  
    setTimeout(function() {  
     alert("Event");  
    }, 540000);  
</script> 
+0

我想,我应该更喜欢在我的项目使用jQuery ..谢谢! – Krown