C#中的浏览器关闭事件 [英] Browser close event in C#

查看:438
本文介绍了C#中的浏览器关闭事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

关闭浏览器时,c#中有可用的事件吗?我知道身体卸载中的javascript功能.但是我要在服务器端吗?

提前谢谢.

问候,
Raj.

Hi All,

Any events are available in c# while we close a browser? i know javascript funtion in body unload. But i want in server side?

Thanks in advance.

Regards,
Raj.

推荐答案

否,因为http是无状态的,所以您只能使用会话超时-如果您希望完全符合标准.但是,您可能会编写一些计时器激活的JS函数,该函数对服务器执行简短的GET,从而使会话保持活动状态.如果您将计时器设置为1s,而会话超时设置为2s,则您会注意到至少2s内失去了连接.但是请注意,这不是关闭浏览器-只是失去连接的时间超过1秒.您可以使用Silverlight,Flash或Java小程序或浏览器插件执行相同的操作.
但是,请尝试想象应用程序的所有用例以及所有的通信情况.
不足以处理正常会话时间的结束吗?
No, as http is stateless, you can only use session timeouts - if you want to be fully standard-conformant. But you might write a little timer activated JS function that performs a short GET to your server, keeping your session alive. If you set the timer to let''s say 1s, and your session timeout to 2s, you will be noticed of connection lost in at least 2s. But be aware, that''s not browser closure - it''s only a connection lost for more than 1s. You can do the same with a Silverlight, Flash or Java applet, or a browser plugin.
But try to imagine all the use-cases of your application, all the communication situations.
Isn''t enough to handle the end of a normal session time?


这篇关于C#中的浏览器关闭事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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