I have a problem with the application state in Asp.net. I need a list of Strings that i would use in different forms in the same application. Here I add the list:
Application.Add("users", new List<String>());
In a new form I try to add a string to the list, but I get NullReferenceException in the second line of the code below.
List<String> ls=(List<String>) Application.Get("users");
ls.Add(TextBox4.Text);
In the first slot of code the string is empty because of
{new List<String>()}. You need to add the string in the list. Only after that, call the Application variable in another form to avoid theNullReferenceExceptionException.