C#登录系统带有’在线/活动状态’?

huangapple go评论61阅读模式
英文:

C# Login system with 'Online/Activity status'?

问题

我正在寻求为我的Web应用程序创建登录系统的最佳方法。这个Web应用程序还有一个我正在开发的Android应用程序,对于那个登录系统我也有同样的问题。

我的问题是,我想要为每个用户显示一个状态,以显示用户是“在线”还是“离线”,但我找不到关于这个主题的太多信息,也不理解如何实现。我的C# Web应用程序目前使用.NET身份验证,并连接到SQLServer数据库来检查用户凭据以获得访问权限。但我不确定如何确保一名用户在登录后是“在线”的,然后在用户未登录时是“离线”的?我也不明白如果用户的计算机死机或用户关闭Web应用程序窗口,它将如何工作。

在Android应用程序中,我也有相同的问题,是否有任何方法可以为Android应用程序提供这种类型的登录“状态”?

如果我的英语不太好,我很抱歉。任何帮助/建议将不胜感激。

英文:

I'm asking for the best method to go down for creating a login system for my web application. This web application also has an android app I am developing and I have the same question for that login system.

My problem is I would like a status for each user to show whether the user is 'online' or 'offline', and I can't find much information on this topic/understand how it would be done. My C# web application currently uses .net Authentication and connects to SQLServer database for user credentials check to gain access to the app. But I'm unsure how I would be able to ensure a user is 'Online' once logged in and then subsequently 'Offline' if a user is not logged in? I also don't understand how it would work if a user's PC died or the user closes the web application window.

This is the same problem I have in android application, is there any methods that would provide this type of login 'status' for an android application?

Sorry If my English is not the best. Any help/suggestions would be greatly appreciated.

答案1

得分: 1

添加列,如Bayram建议的。

添加另一列 "lastKeepAlive",该列是一个日期。在代码中或用户活动中以适当的间隔更新该列。

如果日期早于X,用户将处于离线状态,并可以设置为离线状态。可以更新 "lastKeepAlive"。

可以在应用程序代码中实施,或者作为一个单独运行的进程来实现。

英文:

Add the column as Bayram suggested.

Add another column "lastKeepAlive" that is a date. Update the column at fitting intervals in code and/or on user activity.

If the date is older than X the user is offline, and can be set to offline. "lastKeepAlive" could be updated.

Either implement in app code of a process that runs separately.

答案2

得分: 0

你可以在鼠标活动时将用户显示为在线,并每10分钟更新数据库,如果用户在10分钟内没有活动,系统将自动标记为离线。

英文:

You can show the user to be online when the mouse is active, and update database every 10 minutes, if the user is not active for 10 minutes it will automatically mark as away.

huangapple
  • 本文由 发表于 2023年1月9日 00:36:58
  • 转载请务必保留本文链接:https://go.coder-hub.com/75049538.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定