简体   繁体   English

使用处理程序(ashx)时如何防止会话超时计时器重置?

[英]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: 我对将处理程序与会话超时结合使用有一些疑问:

  1. Does a call to the handler reset the session timeout timer? 调用处理程序是否会重置会话超时计时器?
  2. If so, are there ways to prevent a reset of this timer? 如果是这样,是否有办法防止此计时器复位?

Due to security reasons I would not like my handler to be the cause that my user is logged on indefinitely. 由于安全原因,我不希望我的处理程序成为用户无限期登录的原因。

  1. Yes
  2. Run the handler in a different web app 在其他Web应用程序中运行处理程序

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM