如何处理 global.asax 中的会话结束? [英] How to handle session end in global.asax?

查看:35
本文介绍了如何处理 global.asax 中的会话结束?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在聊天应用程序中工作,我使用 HashTable 来包含用户和操作员作为键 &ChatRoom 类的对象作为 HashTable 的值.主要问题是当用户或操作员关闭浏览器或断开连接而不注销时,它会在会话结束时自动注销.

I'm working in chat application, I used HashTable for containing User and Operator as a Key & Object of ChatRoom Class as a value of HashTable. Main problem is that When user or Operator close browser or disconnected without logout then It is automatically logout on the end of the session.

请帮助我解决这个问题以及如何在这件事上使用 Global.asax.

Please help me related to that and how to use Global.asax in this matter.

推荐答案

可以使用 global.asax 的 session end 事件来移除意外断开的用户:

You can use global.asax's session end event to remove the unexpectedly disconnected user :

void Session_End(Object sender, EventArgs E) {
    // Clean up session resources
}

但请注意,当用户关闭浏览器或连接丢失时,会话不会结束.达到会话超时时结束.

but beware, session doesn't end when the user closes his browser or his connection lost. It ends when the session timeout reached.

这篇关于如何处理 global.asax 中的会话结束?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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