I am trying to create a small web application. I am facing little bit of difficulty with State management in Asp.Net. Even though it is not advisable to store data in application variable, just creating this to understand more about state management.
I am trying to capture user information from a web page, store it in a List and add the List to a Application variable so as to iterate through the stored user values(say user email) and check if the user exist or not.
While testing, I am able to capture the values entered by the first user and when second user enters data, it is getting captured in the application variable but it replaces objects created by the first user.
Is there a way to add multiple objects to application variable and iterate through them? I have declared Application variable in global.asax.cs under Application_Start I have tried the following,
List<userClass> userData = new List<userClass>();
userClass user = new UserClass{
firstName = fnameTextBox.Text;
email = emailTextBox.Text;
};
userData.Add(user);
Application["AllUserDetails"] = userData;