惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

博客园 - silverlightfans

sql server 获取数据库中每个表的磁盘占用情况 扩招的后果(搞笑版) 数据仓库构建实施方法及步骤(转载) treeview非xml数据源绑定 VS 2008 JavaScript Intellisense for Silverlight google 的百毒视频,巨搞笑啊,不知道是不是真的 国际支付平台又添新成员Amazon FPS asp.net 客户端回调功能的实现机制探讨(响应部分及可能的优化) asp.net 客户端回调功能的实现机制探讨(请求部分) 关于为什么web service 构造函数只能是无参数构造函数问题的解答 Silverlight:动态从服务器端获取XAML来绘制前台 javascript附加事件,ff 和 ie 网易的高级提示功能 asp.net ajax 包装得似乎有些过分 PageMethods未定义 的解决 微软为google修改Vista 最好不要使用百分比宽高来创建silverlight Silverlight:一个IE浏览器 利用Tiny Framework 从托管代码中直接操作页面的 DOM元素
黎巴嫩的一位mvp写的一篇文章
silverlightfans · 2007-07-25 · via 博客园 - silverlightfans

早上起来看到在google订阅中看到aspalliance的一篇文章,立即饶有兴趣地阅读起来,题目的标题是:
Handle Browser Close Event on the Server-Side
意为在服务器端捕获浏览器关闭事件。这个技术是一个众所周知的难题,我想看看他是怎么解决的。结果看下去原来使用的body的onunload事件,触发asp.net ajax 的pagemethod来释放服务器端的资源,很奇怪,这样可以吗?当刷新postback,都回导致onunload事件的触发,难道你都要释放一次资源不成?结果在评论的第一条:
This article seemed promising, but unfortunately the javascript chain of events is going to cause undesired results.
第二条评论:
Unfortunately, the code in this article will not work. The onunload event fires every time you leave a page, so you'll be abandoning the session all the time.
接下来的几条评论也都是关于这个does not work的问题,不过倒是有人给了几个不起作用的原因:
1) The user has javascript disabled
2) The user's browser doesn't support javascript
3) The user kills the browser process
4) The user turns off their machine or has a power cut

也有人出了奇招:
One proposed solution is to use the mouse pointer to locate the window close button "X". Off course this will be purely based on the mouse movement but then you should also consider the chances of user resizing the window and then closing it. So, basically what is required is to get the mouse coordinates based on the openned browser window.

总之是不行啦,因为:

The problem with onunload is that it will be fired even if you refresh the page or fire an ASP.NET postback event from any server side button.

不过有人提出的解决办法是:

Another option for this case is that you use a keep alive functionality in your web application. after implementing keep alive, u can keep your session expire time to a short interval, say 1 or 2 mins. through this u can check for the session after every 1 or 2 mins and abandon it accordingly

不过真是汗一个:国外的mvp都写这样的没有经过自己测试的文章,就发布到我觉得如同圣经般的网站上去吗?比起院子里的吕震宇和老赵等大侠,真是要汗一汗了....比起国外的开发人员,园子里的小兄弟们算幸福的了

posted on 2007-07-25 07:14  silverlightfans  阅读(3495)  评论()    收藏  举报