关闭浏览器时不会调用Session_OnEnd [英] Session_OnEnd doesn't get called when shutting down a browser

查看:81
本文介绍了关闭浏览器时不会调用Session_OnEnd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我试图让用户无法在

同时登录网站两次。每次用户登录时,我都会将他们的userID粘贴到

应用程序作用域数组中。如果他们再次尝试登录,我会将它们退回到

错误页面。我使用global.asa中的session_onEnd子来在他们的会话结束时从数组中删除他们的

用户ID,这似乎有效。

罚款。但是,如果我只是关闭浏览器,sub_onEnd似乎没有被调用,所以我无法从应用程序中删除他们的userID

阵列。关于如何强迫这个子射击的任何想法,还是有另一种方式

围绕这个?


tks

解决方案




您可以尝试从< body onunload ="">
$中调用javascript功能b $ b事件在一个窗口中打开一个新的asp页面,并使用那个新的asp页面注销

用户?


HTH

Dan


" Nancy Drew"写道:

大家好

我试图阻止用户在同一时间两次登录网站。每次用户登录时,我都会将他们的用户ID粘贴到应用程序范围的数组中。如果他们再次尝试登录,我会将它们反弹到
错误页面。我使用global.asa中的session_onEnd子在会话结束时从数组中删除他们的
userID,这似乎工作正常。但是,如果我只是关闭浏览器,sub_onEnd似乎没有被调用,所以我无法从应用程序
数组中删除他们的userID。关于如何强迫这个潜艇开火的任何想法,还是有另外一种方式围绕这个?



嘿丹


好​​主意。一个问题可能是用户有一个弹出窗口阻止程序,或者没有客户端脚本的b
。我希望尽可能提供服务器端解决方案吗?


可能仍会沿着这条路走。


tks

Dan Nash < da*@musoswire.co.uk>在消息中写道

新闻:C4 ********************************** @ microsof t.com ...



您可以尝试从< body onunload ="">
事件中调用javascript函数在一个窗口中打开一个新的asp页面,并使用那个新的asp页面来
注销用户?

HTH

Dan

Nancy Drew写道:

大家好

我试图阻止用户在同一时间两次登录网站。每次用户登录时,我都会将他们的用户ID粘贴到应用程序范围的数组中。如果他们再次尝试登录,我会将它们反弹到
错误页面。我使用global.asa中的session_onEnd子在会话结束时从数组中删除
他们的userID,这似乎是
工作正常。但是,如果我只是关闭浏览器,sub_onEnd似乎没有
被调用,所以我无法从应用程序
数组中删除他们的userID。关于如何强迫这个子射击的任何想法,或者是否还有另外的
方式?



>好主意。一个问题可能是用户有一个弹出窗口阻止程序,或者没有

客户端脚本。我希望有可能提供服务器端解决方案吗?




抱歉,服务器无法拦截浏览器关闭事件,也无法拦截

检测有人关闭他们的系统,绊倒电源线等。

记住ASP是如何工作的:向服务器发出请求,ASP代码运行

在服务器上,并返回HTML和客户端代码到客户端。在这个

点,ASP无法观察对于像这样的事件,因为ASP代码没有

更长时间存在......它只是达到目的的手段。这是HTTP的无状态

性质,您只能通过

建立新连接再次与服务器端通信。从关闭

窗口中执行此操作的唯一方法是使用onunload hack。

http://www.aspfaq.com/2265
http://www.aspfaq.com/2078
http://www.aspfaq.com/2491


hi all

i''m trying to keep users from being able to login to a site twice at the
same time. everytime a user does a login, i stick their userID into an
application scoped array. if they try to login again, i bounce them to an
error page. i use the session_onEnd sub within global.asa to remove their
userID from the array at the end of their session, and this seems to work
fine. however, if i just shut down the browser, the sub_onEnd doesn''t seem
to get called, so i''m unable to remove their userID from the application
array. any ideas on how to force this sub to fire, or is there another way
around this?

tks

解决方案

Hi,

You could try calling a javascript funtion from your <body onunload="">
event to open a new asp page in a window, and use that new asp page to logout
the user?

HTH
Dan

"Nancy Drew" wrote:

hi all

i''m trying to keep users from being able to login to a site twice at the
same time. everytime a user does a login, i stick their userID into an
application scoped array. if they try to login again, i bounce them to an
error page. i use the session_onEnd sub within global.asa to remove their
userID from the array at the end of their session, and this seems to work
fine. however, if i just shut down the browser, the sub_onEnd doesn''t seem
to get called, so i''m unable to remove their userID from the application
array. any ideas on how to force this sub to fire, or is there another way
around this?

tks



hey dan

excellent idea. one problem may be that the user has a pop-up blocker, or no
client side scripting. i''m hoping for a server side solution if possible?

may still go this route, though.

tks
"Dan Nash" <da*@musoswire.co.uk> wrote in message
news:C4**********************************@microsof t.com...

Hi,

You could try calling a javascript funtion from your <body onunload="">
event to open a new asp page in a window, and use that new asp page to logout the user?

HTH
Dan

"Nancy Drew" wrote:

hi all

i''m trying to keep users from being able to login to a site twice at the
same time. everytime a user does a login, i stick their userID into an
application scoped array. if they try to login again, i bounce them to an error page. i use the session_onEnd sub within global.asa to remove their userID from the array at the end of their session, and this seems to work fine. however, if i just shut down the browser, the sub_onEnd doesn''t seem to get called, so i''m unable to remove their userID from the application
array. any ideas on how to force this sub to fire, or is there another way around this?

tks



> excellent idea. one problem may be that the user has a pop-up blocker, or
no

client side scripting. i''m hoping for a server side solution if possible?



Sorry, but the server can''t intercept browser close events, nor can it
detect someone shutting down their system, tripping on the power cord, etc.
Remember how ASP works: a request is made to the server, the ASP code runs
on the server, and returns HTML and client-side code to the client. At this
point, ASP cannot "watch" for events like this, because the ASP code no
longer exists... it was merely a means to an end. This is the stateless
nature of HTTP, and you can only talk to the server side again by
establishing a new connection. And the only way to do that from a closing
window is to use the onunload hack.

http://www.aspfaq.com/2265
http://www.aspfaq.com/2078
http://www.aspfaq.com/2491


这篇关于关闭浏览器时不会调用Session_OnEnd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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