获取ASP.NET会话上次访问时间(或时间对超时) [英] Get ASP.NET Session Last Access Time (or Time-to-Timeout)

查看:145
本文介绍了获取ASP.NET会话上次访问时间(或时间对超时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图确定有多少时间在一个给定的ASP.NET会话留直到超时。

I'm trying to determine how much time is left in a given ASP.NET session until it times out.

如果没有现成的时间对超时值,我也可以从上次访问时间计算的话(但我没有找到任何这一点)。任何想法如何做到这一点?

If there is no readily available time-to-timeout value, I could also calculate it from its last access time (but I didn't find this either). Any idea how to do this?

推荐答案

如果你在服务器处理请求,然后超时刚刚被复位,因此整整20分钟(或任何你配置)依然存在。

If you are at the server, processing the request, then the timeout has just been reset so the full 20 minutes (or whatever you configured) remain.

如果你想有一个客户端的警告,你需要创建一些JavaScript code将从现在火约20分钟。见setTimeout的方法。

If you want a client-side warning, you will need to create some javascript code that will fire about 20 minutes from "now". See the setTimeout method.

我已经使用了被请求的页面后显示警告,15分钟。它弹出像一个警告您的会议{HH:MM}将过期,请保存你的工作。确切的时间来代替在5分钟内因为你永远不知道,当用户将看到消息(他才解雇警报10分钟后回到他的电脑?)。

I have used that to display a warning, 15 minutes after the page was requested. It pops up an alert like "your session will expire on {HH:mm}, please save your work". The exact time was used instead of "in 5 minutes" as you never know when the user will see that message (did he return to his computer 10 minutes after the alert fired?).

这篇关于获取ASP.NET会话上次访问时间(或时间对超时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆