防止 Session.Timeout 延长

发布于 2024-11-24 16:44:07 字数 573 浏览 2 评论 0原文

如何防止代码隐藏中某些事件的 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 分钟后结束(如果用户仍然没有从浏览器发送任何请求) 。

How to prevent Session.Timeout extension on certain event from codebehind?

<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;
}

Initial calculations was that 1 minute before the session ends, i'll inform the user something with the ModalPopup. The problem is that when this Timer7_Tick event triggers, the Session.Timeout renew and the session ends 10 minutes later (if user still don't send any request from his browser).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

若有似无的小暗淡 2024-12-01 16:44:07

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

15+ jQuery 弹出模式对话框插件和教程。< /code>

使用 Timer 控件 的替代方法是使用以下 JavaScript:

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

Server side execution will extend session timeout. If you just want to popup a dialog, try using JavaScript without any postbacks.

15+ jQuery Popup Modal Dialog Plugins and Tutorials.

An alternative of using Timer control, use this JavaScript:

<script type="text/javascript">    
    setTimeout(function () {    
        alert("Event");    
    }, 540000);    
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文