0

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.

1 Answer 1

2

So I would need to keep my table of active users somewhere persistant something that does not get erased on refresh.

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

Sign up to request clarification or add additional context in comments.

6 Comments

How about Application('users', array()); I'm guessing it's the same thing. Tho i was told i should be able to implement this via Application()
@kellax Application variables are a simple static variable. You can not keep it there and have it as you like, on recycle of the pool you going to lose them, Make a test and you see it.
Since I'm very i googled " Pool Recycle " but couldnt find what that is. Page reload/refresh or ?
@kellax Totally lost you. You look for a place to share/save some data, if you place them there on application, then they going to be erase if the pool recycle. Google "application pool recycle asp.net"
By default it recycles ever 29 hours? If so than this should be very good for me. Thanks for the input tho helped a lot.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.