简体   繁体   English

会话在超时前过期

[英]Session getting expired before timeout

I have configured the cookieless session_state in ASP.Net Web API and timeout is 20 minutes. 我已在ASP.Net Web API中配置了cookielessless session_state,超时时间为20分钟。

<sessionState mode="InProc" timeout="20" />

On every new session established I am storing session_id generated in a dictionary to keep track of sessions, and respectively removes the session_id from dictionary whenever session_end. 在建立的每个新会话上,我都会存储在字典中生成的session_id来跟踪会话,并在每次session_end时分别从字典中删除session_id。

But I am facing a strange issue (not very frequently), whenever a new user establishes the session it is expired immediately and the session_id is removed from the dictionary. 但是我遇到一个奇怪的问题(不是很频繁),每当新用户建立会话时,该会话立即过期,并将session_id从字典中删除。

Session_End code: Session_End代码:

protected void Session_End()
    {
        var sessionId = this.Session.SessionID;
        if (SessionDictionary.ContainsKey(sessionId))
        {
            SessionDictionary.Remove(sessionId);
        }
    }

So please if someone can guide me on this. 因此,请有人指导我。 Also, I have a doubt whether "this.Session.SessionID" refers to session_id which is expired or the one which is currently created. 另外,我怀疑“ this.Session.SessionID”是指已经过期的session_id还是当前创建的session_id。

Thanks in advance 提前致谢

Are you behind a load balancer? 您在负载均衡器后面吗? If so you could just be hitting a server in your farm that doesn't actually have the session setup as its specific to each server as you declared it as in process 如果是这样,您可能只是在服务器场中碰到一台服务器,而该服务器实际上并未像您声明的那样正在对每个服务器设置会话设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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