如何在浏览器关闭时在ASP.Net Identity中注销用户? [英] How to Signout user in ASP.Net Identity when browser closed ?

查看:66
本文介绍了如何在浏览器关闭时在ASP.Net Identity中注销用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在浏览器关闭时在ASP.Net Identity中注销用户?

How to Signout user in ASP.Net Identity when browser closed ?

推荐答案

您不能因为您的网站不知道用户是否已关闭浏览器。
You can't as your website doesn't know if the user has closed the browser.


如评论中所述,没有完美的方法可以做到这一点,所以我建议你甚至不要打扰。但是,您可以在JS中使用窗口的onbeforeunload事件并调用Web服务将其注销。但您无法确定他们是否未在浏览器的另一个标签页中打开您的网站。
As mentioned in the comments, there is no perfect way to do it so I suggest you don't even bother. However, you can use the onbeforeunload event of a window in JS and call a webservice to log them out. But you can't be sure they didn't open your site in another tab of the browser.


这篇关于如何在浏览器关闭时在ASP.Net Identity中注销用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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