Global.asax:Session_End()行为 [英] Global.asax: Session_End() Behavior

查看:45
本文介绍了Global.asax:Session_End()行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。我正在努力维护一份目前在线的人员名单。在

SQL中。我这样做是通过在一个简单的PeopleOnline表中添加一个简单的条目

,只要有人登录我的网站。


如果他们手动登录网站,从PeopleOnline表中删除它们没有问题。

但是,如果他们只是关闭浏览器,我假设

我必须使用Global.asax中的Session_End()事件,即使我知道

这将是只有在用户的会话超时后才会出现。


但是我有两个问题:


1.当这个甚至发生了,我还可以访问该用户的会话吗?在其他

字里面,在Session_End()函数中,我可以引用Session []

对象吗?


2。在从VS2005开发期间,我该如何测试?问题是

当我关闭我在VS中使用的broswer,所有类型的死亡

所以我不认为Session_End()曾经发生过。我该怎么调试?


谢谢。


Alex

解决方案

关于这一点的更多信息 - 我*已经弄清楚如果我将超时设置为

短。但是我仍然不知道为什么Session_End发生时会话中的对象似乎消失了




" Alex Maghen"写道:


嗨。我正在努力维护一份目前在线的人员名单。在

SQL中。我这样做是通过在一个简单的PeopleOnline表中添加一个简单的条目

,只要有人登录我的网站。


如果他们手动登录网站,从PeopleOnline表中删除它们没有问题。

但是,如果他们只是关闭浏览器,我假设

我必须使用Global.asax中的Session_End()事件,即使我知道

这将是只有在用户的会话超时后才会出现。


但是我有两个问题:


1.当这个甚至发生了,我还可以访问该用户的会话吗?在其他

字里面,在Session_End()函数中,我可以引用Session []

对象吗?


2。在从VS2005开发期间,我该如何测试?问题是

当我关闭我在VS中使用的broswer,所有类型的死亡

所以我不认为Session_End()曾经发生过。我该怎么调试?


谢谢。


Alex


re:

!在Session_End发生的时候,我仍然不知道为什么会话中的对象似乎消失了



当Session_End事件触发它时,因为会话已经消失,

由于会话超时或者已经在代码中调用了Session.Abandon。


ASP.NET需要具有通灵性才能拥有Pre_Session_End。事件。




Session_End事件处理程序中唯一可用的内置对象是服务器和应用程序。



Juan T. Llibre,asp.net MVP

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/

===== =================================

" Alex Maghen" < Al ******** @ newsgroup.nospamwrote in message

news:47 ********************** ************ @ microsof t.com ...


更多关于这一点 - 我*弄明白如果我设置暂停时间

短。但是我仍然不知道为什么Session_End发生时会话中的对象似乎消失了




" Alex Maghen"写道:


>嗨。我正在努力维护一份目前在线的人员名单。在
SQL中。我这样做是通过在一个简单的PeopleOnline表中添加一个简单的条目
每当有人登录我的网站时。

如果他们手动登录网站,我没有问题从
PeopleOnline表。但是如果他们只关闭浏览器,我就是假设
我必须在Global.asax中使用Session_End()事件,即使我知道这只会在用户'会议已超时。

但我有两个问题:

1。当这种情况发生时,我仍然可以访问该用户的会话吗?用其他的话说,在Session_End()函数里面,我可以引用Session []
对象吗?

2。在从VS2005开发期间,我该如何测试?问题是,当我关闭我在VS中使用的broswer时,所有类型的死亡
所以我不认为Session_End()曾经发生过。我该怎么调试?

谢谢。

Alex




嗯,我猜我得到的不是那个,事实上,ASP就是在这一点上杀死了Session(因为超时)。因此,它不应该是心灵的。实现前端会话。此外,我已经进行了一些实验,实际上,我*可以*在Global.asax Session_End()事件中将对象从

会话中取回。有一些奇怪的

差异,但Session []中的简单对象似乎是可靠的。


Alex


Juan T. Llibre写道:


re:

!我仍然不知道为什么会话中的对象似乎消失了

!当Session_End发生时。


当Session_End事件触发它时,因为会话已经消失,

要么是因为a会话超时或已在代码中调用Session.Abandon。


ASP.NET需要具有通灵性才能拥有Pre_Session_End。事件。




Session_End事件处理程序中唯一可用的内置对象是服务器和应用程序。



Juan T. Llibre,asp.net MVP

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?±ol: http://asp.net.do/foros/

==== ==================================

" Alex Maghen" < Al ******** @ newsgroup.nospamwrote in message

news:47 ********************** ************ @ microsof t.com ...


更多关于这一点 - 我*弄明白如果我设置暂停时间

短。但是我仍然不知道为什么Session_End发生时会话中的对象似乎消失了




" Alex Maghen"写道:


嗨。我正在努力维护一份目前在线的人员名单。在

SQL中。我这样做是通过在一个简单的PeopleOnline表中添加一个简单的条目

,只要有人登录我的网站。


如果他们手动登录网站,从PeopleOnline表中删除它们没有问题。

但是,如果他们只是关闭浏览器,我假设

我必须使用Global.asax中的Session_End()事件,即使我知道

这将是只有在用户的会话超时后才会出现。


但是我有两个问题:


1.当这个甚至发生了,我还可以访问该用户的会话吗?在其他

字里面,在Session_End()函数中,我可以引用Session []

对象吗?


2。在从VS2005开发期间,我该如何测试?问题是

当我关闭我在VS中使用的broswer,所有类型的死亡

所以我不认为Session_End()曾经发生过。我该怎么调试?


谢谢。


Alex



Hi. I am trying to maintain a list of people who are currently "online" in
SQL. I do this by adding a simple entry to a simple PeopleOnline table
whenever someone logs in to my site.

If they manually log OUT of the site, I have no problem deleting them from
the PeopleOnline table. But if they just close the browser, I was assuming
I''d have to use the Session_End() event in Global.asax even though I know
that this will only occur once the user''s session has timed out.

But I have two questions about this:

1. When this even occurs, can I still access that user''s Session? In other
words, inside the Session_End() function, can I reference the Session[]
object?

2. During development from VS2005, how do I test this? The problem is that
when I close the broswer that I use from within VS, everything sort of dies
so I don''t think that the Session_End() ever occurs. How can I debug?

Thanks.

Alex

解决方案

More about this - I *have* figure out that if I set the timeout to something
short. But I still don''t know why objects in the session seem to be gone by
the time Session_End occurs.

"Alex Maghen" wrote:

Hi. I am trying to maintain a list of people who are currently "online" in
SQL. I do this by adding a simple entry to a simple PeopleOnline table
whenever someone logs in to my site.

If they manually log OUT of the site, I have no problem deleting them from
the PeopleOnline table. But if they just close the browser, I was assuming
I''d have to use the Session_End() event in Global.asax even though I know
that this will only occur once the user''s session has timed out.

But I have two questions about this:

1. When this even occurs, can I still access that user''s Session? In other
words, inside the Session_End() function, can I reference the Session[]
object?

2. During development from VS2005, how do I test this? The problem is that
when I close the broswer that I use from within VS, everything sort of dies
so I don''t think that the Session_End() ever occurs. How can I debug?

Thanks.

Alex


re:
!I still don''t know why objects in the session seem to be gone
!by the time Session_End occurs.

When the Session_End event fires it''s because the session is already gone,
either due to a session timeout or to Session.Abandon having been called in code.

ASP.NET would need to be psychic in order to have a "Pre_Session_End" event.

The only built-in objects available from within the
Session_End event handler are Server and Application.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Alex Maghen" <Al********@newsgroup.nospamwrote in message
news:47**********************************@microsof t.com...

More about this - I *have* figure out that if I set the timeout to something
short. But I still don''t know why objects in the session seem to be gone by
the time Session_End occurs.

"Alex Maghen" wrote:

>Hi. I am trying to maintain a list of people who are currently "online" in
SQL. I do this by adding a simple entry to a simple PeopleOnline table
whenever someone logs in to my site.

If they manually log OUT of the site, I have no problem deleting them from
the PeopleOnline table. But if they just close the browser, I was assuming
I''d have to use the Session_End() event in Global.asax even though I know
that this will only occur once the user''s session has timed out.

But I have two questions about this:

1. When this even occurs, can I still access that user''s Session? In other
words, inside the Session_End() function, can I reference the Session[]
object?

2. During development from VS2005, how do I test this? The problem is that
when I close the broswer that I use from within VS, everything sort of dies
so I don''t think that the Session_End() ever occurs. How can I debug?

Thanks.

Alex




Well, I guess what I don''t get about that is that, in fact, it is ASP that is
killing the Session at this point (because of timeout). So therefore it
shouldn''t have to be "psychic" to implement a "Pre-end-Session." Further, I
have experimented a little and, in fact, I *can* get objects back out of the
Session within the Global.asax Session_End() event. There are some strange
differences, but simple objects in Session[] seem to be reliably available.

Alex

"Juan T. Llibre" wrote:

re:
!I still don''t know why objects in the session seem to be gone
!by the time Session_End occurs.

When the Session_End event fires it''s because the session is already gone,
either due to a session timeout or to Session.Abandon having been called in code.

ASP.NET would need to be psychic in order to have a "Pre_Session_End" event.

The only built-in objects available from within the
Session_End event handler are Server and Application.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?±ol : http://asp.net.do/foros/
======================================
"Alex Maghen" <Al********@newsgroup.nospamwrote in message
news:47**********************************@microsof t.com...

More about this - I *have* figure out that if I set the timeout to something
short. But I still don''t know why objects in the session seem to be gone by
the time Session_End occurs.

"Alex Maghen" wrote:

Hi. I am trying to maintain a list of people who are currently "online" in
SQL. I do this by adding a simple entry to a simple PeopleOnline table
whenever someone logs in to my site.

If they manually log OUT of the site, I have no problem deleting them from
the PeopleOnline table. But if they just close the browser, I was assuming
I''d have to use the Session_End() event in Global.asax even though I know
that this will only occur once the user''s session has timed out.

But I have two questions about this:

1. When this even occurs, can I still access that user''s Session? In other
words, inside the Session_End() function, can I reference the Session[]
object?

2. During development from VS2005, how do I test this? The problem is that
when I close the broswer that I use from within VS, everything sort of dies
so I don''t think that the Session_End() ever occurs. How can I debug?

Thanks.

Alex



这篇关于Global.asax:Session_End()行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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