I have used below code to find out more than one login attempts by users in an application using asp.net.

Dictionary<string, string> dict = HttpContext.Current.Application["UserID"] as Dictionary<string, string>;
string UserID = Param.Split(',')[0];
string ID = Param.Split(',')[1]; 
HttpContext.Current.Session["UserID"] = UserID.ToString();
HttpContext.Current.Session["UserName"] = UserDetails[0].UserName.ToString();
HttpContext.Current.Session["LoginPKId"] = ID;
if (dict != null)
{
 lock (dict)
  {
    // User is already logged in!!!
   if (dict.ContainsValue(HttpContext.Current.Session["UserID"].ToString().ToLower()))
   {
     if (dict.ContainsKey(HttpContext.Current.Session["LoginPKId"].ToString()))
     {
       UserDetails.Add(new UserDetails()
       {
          UserName = UserID.ToString(),
          SessionAvailable = "Y".ToString(),
        });
     }
     else
     {
         string strDictVal = "";
         var result = dict.Where(c => c.Value == HttpContext.Current.Session["UserID"].ToString().ToLower());
         foreach (var item in result)
         {
           strDictVal = item.Key;
         }
         LstUserDetails.Add(new UserDetails()
         {
           UserName = UserID.ToString(),
           SessionAvailable = "N".ToString(),
           LoginId = strDictVal 
          });
         }
      }
     else
     {
        strUserId = HttpContext.Current.Session["UserID"].ToString().ToLower();
        UserDetails.Add(new UserDetails()
        {
          UserName = UserID.ToString(),
          SessionAvailable = "Y".ToString(),
         });
         dict.Add(loginpkid, HttpContext.Current.Session["UserID"].ToString().ToLower());
      }
    }
 }

I have successfully find out concurrent login users in the application using Application variable. Is there any possibility to find out concurrent login users using SignalR in asp.net?

Related posts

Recent Viewed