想要运行一些服务器端代码,即使用户使用十字按钮关闭浏览器 [英] want to run some server side code even if user closes the browser with cross button

查看:71
本文介绍了想要运行一些服务器端代码,即使用户使用十字按钮关闭浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助

在我的应用程序中,我正在Page_Unload事件中更新数据库中的某些值

当用户只是简单地通过十字按钮关闭浏览器时,此功能不起作用

我通过谷歌搜索找到了一个主题,该主题需要在global.asax文件中编写一些代码,并需要调用会话结束函数.我不明白.

在这里找到主题
"target =" _ blank"title ="新窗口> ^ ]

如果您知道完整的过程,请在此处提供,或者如果您有其他想法,请提出,迫切需要.

Please help

In my application, i am updating some values in database in Page_Unload event

this function doesn''t works when user just simply closes the browser from cross button

I found a topic through googling where some code needs to be written in global.asax file and session end function needs to be called. I didn''t understand it.

find the topic here
http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide.all[^]

If you know the complete procedure please provide here or if u have an another idea,please bring up, urgently needed.

推荐答案

用户关闭浏览器窗口时,她或他不想更新任何值.这不合逻辑吗?

关闭浏览器意味着用户要取消或当前操作,完全放弃屏幕上修改的数据.您为什么还要忽略该合法用户的决定,并强迫该用户进行意外更新?如果您这样做,谁会使用您的应用程序?谢天谢地,你做不到.

—SA
It the user closes browser window, she or he does not want to update any values. Isn''t this logical?

Closing browser means the user wants to cancel or current operation, quite and abandon the data modified on screen. Why would you even want to ignore this legitimate user''s decision and force the user into unintended update? Who would use your application if you did that? Thanks goodness, you cannot do it.

—SA


当用户未遵循正确的注销程序时,我需要更新数据库中的某些值.我需要更新他关闭浏览器的时间.登录我的应用程序的时间是必需的.
I need to update some values in database when user does not follow the proper procedure of logout.I need to update time he closed the browser.The time is mandatory to log for my application


您可以在用户每次执行导致回发(或最初打开页面)的操作时更新数据库.然后,下一次他登录时,请设置他上一次在站点上执行操作时的注销时间.当然,您必须决定是要一直为给定用户使用同一条记录,还是要为每个会话使用一条新记录.
You could update the database every time the user does something that causes a postback (or initially opens a page). Then then next time he logs on, set the log off time for the last time he did something on the site. Of course, you''d have to decide if you wanted to use the same record all the time for a given user, or have a new record for each session.


这篇关于想要运行一些服务器端代码,即使用户使用十字按钮关闭浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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