当 Timer 事件刷新 UpdatePanel 的内容时,如何防止重置会话超时?

发布于 2024-07-17 15:16:10 字数 337 浏览 5 评论 0原文

我们的 ASP.net Ajax 应用程序中有几个页面可以根据计时器事件自动刷新 UpdatePanels 内容,但问题是我们需要使 Web 会话超时,而自动刷新会阻止这种情况发生。

有没有办法防止计时器回发事件修改 Web 会话或任何其他替代解决方案以允许 Web 会话在自动刷新 UpdatePanel 内容时超时?

下面举一个例子来说明这个问题。 我将会话超时设置为 3 分钟,并在 UpdatePanel 中设置一个计时器,每分钟计时一次,并根据当前状态修改 UpdatePanel 的内容。 登录后,我导航到此页面,5 分钟内什么都不做,然后尝试单击另一个页面,但由于会话没有超时,我仍然处于登录状态。

We have several pages in our ASP.net Ajax application which auto refresh the UpdatePanels contents based on a timer event but the problem is that we have a requirement to timeout the web session and the auto refresh is preventing that.

Is there a way to prevent the timer postback event from modifying the web session or any other alternate solution to allow the web session to timeout while auto refreshing the UpdatePanel contents?

Here is an example to illustrate this problem. I set the session timeout to 3 minutes and have a timer in the UpdatePanel that ticks every minute and modifies the contents of the UpdatePanel based on the current state. After logging in, I navigate to this page and do nothing for 5 minutes and then try and click on another page and I am still logged in since the session didn't time out.

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

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

发布评论

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

评论(1

初心未许 2024-07-24 15:16:10

您可以在客户端跟踪用户的活动。 如果没有鼠标移动等,您可以使用 Sys.Services.AuthenticationService 类(Microsoft AJAX 库 1.0 的一部分)。 您可以在实际注销之前弹出确认信息,以便用户在场时可以取消注销。 注销时,您可以向用户弹出一条消息,说明他因不活动而自动注销。

我的解决方案将如何解决您的场景:

您将会话超时设置为 3 分钟,并在 UpdatePanel 中设置一个计时器,该计时器每分钟计时一次,并根据当前状态修改 UpdatePanel 的内容。 登录后,您将导航到此页面,但不执行任何操作。 3 分钟没有任何活动后,您会向用户弹出一条确认消息,要求他使用 Sys.Services.AuthenticationService 取消自动注销。 如果用户仍未采取任何操作,您将在几秒钟后将其注销。 您弹出一条“已注销消息”,用户在 5 分钟后返回浏览器时将看到该消息。 当他点击另一个页面时,他还没有登录。

You may track the activity of the user on the client side. If there is no mouse move etc. you could log the user out using the Sys.Services.AuthenticationService class (part of Microsoft AJAX Library 1.0). You could pop a confirmation before you do the actual log out, so that the user may cancel it if he is present. When logged out you could pop a message to the user saying that he was automatically logged out because of inactivity.

How my solution would solve your scenario:

You set the session timeout to 3 minutes and have a timer in the UpdatePanel that ticks every minute and modifies the contents of the UpdatePanel based on the current state. After logging in, you navigate to this page and do nothing. After 3 minutes of no activity you pop a confirmation to the user asking him to cancel automatic log out using the Sys.Services.AuthenticationService. If the user still takes no action you log him out after a few seconds. You pop a "logged out message" that the user will see when he returns to the browser after 5 minutes. When he then click on another page he is not logged in.

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