[英]How to prevent reset of session timeout timer when using handler (ashx)?
I'm using a handler to poll certain information out my application. 我正在使用处理程序从应用程序中轮询某些信息。 I've got some questions about using the handler in combination with session timeout:
我对将处理程序与会话超时结合使用有一些疑问:
Due to security reasons I would not like my handler to be the cause that my user is logged on indefinitely. 由于安全原因,我不希望我的处理程序成为用户无限期登录的原因。
The only solution I can think of is to do some kind of manual session timeout handling. 我能想到的唯一解决方案是执行某种手动会话超时处理。 Something like this:
像这样:
void Application_BeginRequest(object sender, EventArgs e)
{
if(Session["LastAccessTime"] != null && (DateTime)Session["LastAccessTime"] < DateTime.Now.AddMinutes(-20))
Session.Abandon();
if(Request.RawUrl != "/MyHandler.ashx")
Session["LastAccessTime"] = DateTime.Now;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.