I’m programming a Chat. Basically, I have a window (TextBox) where I want to display all users that are in the conversation at the moment but I do not wish to use a database.
So, I would need to keep my table of active users somewhere persistent something that does not get erased on refresh.
I looked in to Sessions. However, they expire and I can’t keep the array of my active users in there. I also looked in Application Object and it seems this could solve my dilemma. However:
Say I call
String[] users = new users String[1000];
Application['users'] = users;
In my Page_Load() method, sure I can store the new user in to that table but then each page load will override the table and I will always show only one user but I guess implementing something along lines is isset() could solve that.
A database is the solution for that.
The
Application[]is actually a static variable, so its delete it when pool recycle, and also if you have more than one pool, than you have more than one common Application variables.Read about application state: Using static variables instead of Application state in ASP.NET
See some other examples with asp.net chat:
http://www.codeproject.com/Articles/33817/Build-a-Web-based-Chat-using-ASP-NET-Ajax