且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检查用户是否已经在asp.net中登录Web应用程序

更新时间:2023-12-04 18:07:52

如果您使用的是表单身份验证,请
If you are using Forms Authentication,
System.Web.HttpContext.Current.User.Identity.IsAuthenticated

>可以为您提供此信息.

can give you this information.


您可以通过两种方式实现.
服务器端缓存变量或使用哈希表或仅维护当前登录用户的任何对象作为应用程序变量.
或者,您可以在登录后将数据库中用户的活动状态设置为1,然后在再次登录之前参考该状态.
You can implement this in two ways.
Server side caching variable or as an application variable using hashtable or any object which just maintains the current loggin users.
Or you can set the active state of the user in database as 1 once logged and refer to that before logging again.