how to check the duplicate in Application state
My problem scenario:
I stored the username and password in the application[“”] variable.
another user enters the username password i want to check for each and every user.
i tried for for loop but hard to find the count..
could you help me check the duplicate
for (int j = 0; j < (int)System.Web.HttpContext.Current.Application["Userlogin"].ToString().Length - 1; j++)
{
if (System.Web.HttpContext.Current.Application[i].ToString() == sKey)
{
Session["duplicateuser"] = "logout";
Returnmsg = "-3";
}
}
but it shows the string length of the application[]
Thank in Advance
Wow, don’t. The Application state is shared among all users of your application. Never store user specific data in application state. Use Session state instead.
UPDATE:
If you want to check for concurrent user access you could store a collection of users into the application state such as
IEnumerable<string>. Then you could check if a user is already logged in easily: