如何在 ASP.NET 中提醒用户会话即将过期?

发布于 2024-08-12 02:40:58 字数 241 浏览 3 评论 0原文

我有一个场景,我想向我的应用程序的用户显示一条消息,提醒他们他的会话即将过期,并且他应该保存他的工作以避免丢失他的工作。

这是一个典型的场景,用户在文本框中输入信息,然后让他的计算机暂时无人看管。然后,当他按下提交按钮保存工作时,他会被重定向到登录页面,因为他的会话已过期,因此必须在文本框中再次输入所有信息。

如何使用 ASP.NET 2.0/3.5 在屏幕上显示警报消息?

预先感谢您的指导。

G。

I have a scenario where I would like to display a message to the users of my application alerting them that his session will expire soon and that he should save his work to avoid the loss of his work.

This would be a typical scenario where a user is typing information on a textbox and then leaves his computer unattended for a while. Then when he presses a submit button to save his work, he is redirected to login page because his session expired, thus having to type all his information again in the textbox.

How can an alert message be displayed on the screen using ASP.NET 2.0/3.5?

Thanks in advance for your guidance.

G.

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

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

发布评论

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

评论(3

浅浅淡淡 2024-08-19 02:40:58

如果用户离开计算机的时间超过 20 分钟,提醒就没多大用处。会话仍会超时。您最好保持会话处于活动状态:

Reminders are not going to be much use if the user has left their computer for any period of time over 20 mins. The session will still time out. You'd be better off keeping the session alive:

々眼睛长脚气 2024-08-19 02:40:58

要回答我自己的问题,看起来实现此目的的最佳方法是使用 setTimeout javascript 函数在会话超时前 X 分钟发出提醒。

To answer my own question, looks like the best way to accomplish this is to use a setTimeout javascript function to alert a reminder X mins before the session timeout.

扎心 2024-08-19 02:40:58

一种方法是注册 ClientScript

将会话过期值传递给客户端 Java 脚本。这将执行倒计时,并在最后显示弹出窗口。

One way to do this is by registing ClientScript.

Pass the session expiry value to the client side java script. Which will execute a countdown, and at the end display the Popup.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文