How do I know if a user is logged in?

In any case, can I create a function that receives both the username and the function returns if the user is currently logged into the application?

+3
source share
3 answers

Take a look

this.Page.User.Identity
+1
source

The class System.Web.Security.MembershipUserhas a IsOnlineboolean property , so you can do something like this.

MembershipUser user = Membership.GetUser(username);
if (user != null)
  return user.IsOnline;

// handle User not found here, or just return false..
return false;
+1
source
Session.Add("CurrentUser", currentUser);

, . ASP.NET #, , .

_currentUser = ([].User)Session["CurrentUser"];

if (_currentUser != null)
{
}
0

Source: https://habr.com/ru/post/1760766/


All Articles