任何建议都会受到批评 [英] any suggesition will be appriciated

查看:85
本文介绍了任何建议都会受到批评的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何建议都会被登录

登录表单当用户按下登录按钮时,同时也会更新sql db tbl列。表列是位数据类型。因此,当用户按下登录按钮时,列将更新为True。那将是用户现在登录的样子。但是,当用户关闭浏览器时,数据库列仍将具有值True。任何想法如果关闭浏览器后如何更新表值,如果可能吗??

解决方案

基本上,你不能 - 没有可靠的方法适用于所有人浏览器,即使有,如果停电也无济于事,或者浏览器以结束任务关闭。



执行此操作的最佳方法是在会话到期时终止数据库:这样,它与客户端发生的情况无关。请参阅会话状态事件 [ ^ ]并查看Session_OnEnd事件。


网络是无状态所以你的服务器端代码不知道用户是否在那里(他们可能正在查看你的网站,他们可能已经移动到另一个网站,他们可能关闭了他们的浏览器,他们可能只是远离他们的桌面......你只是不知道,所以没有必要做你想做的事。



如果你想跟踪谁在 - 那么你真正做的最好的就是每当有人访问一个页面时记录,并假设那些暂时没有访问过页面的人不再活跃。



跟踪哪些用户当前有效ASP.NET论坛 [ ^ ]



事情你不应该花时间做| ASP.NET论坛 [ ^ ]

any suggesition will be appriciated
in login form When user press login Button, at same time also a sql db tbl column is updated. Table column is a Bit data type. So when user press login Button, column is updated to True. That would be look like that user is login at the moment. But, when user is close Browser, database column will still have value True. Any idea how to update table value even after closing browser if is it possible??

解决方案

Basically, you can't - there is no reliable method that works for all browsers, and even if there were, that wouldn't help if there was a power cut, for example, or the browser is closed with "End Task".

The best way to do this is to kill the DB when the Session expires: that way it's independent of what happens at the client. See Session-State Events[^] and look at the Session_OnEnd event.


The web is stateless so your server-side code doesn't know if the user is there or not (they could be looking at your site, they might have moved to another site, they might have closed their browser, they might just be away from their desk...you just don't know), so there is no point doing what you're trying to do.

If you want to track who is on-line then the best you can really do is record every time someone accesses a page and assume those who haven't accessed a page for a while is no longer active.

Tracking which users are currently active | The ASP.NET Forums[^]

Things you shouldn't spend time doing | The ASP.NET Forums[^]


这篇关于任何建议都会受到批评的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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