0

私はチャットをプログラミングしています。基本的にTextBox、現在会話中のすべてのユーザーを表示したいウィンドウ()がありますが、データベースは使用したくありません。

したがって、アクティブユーザーのテーブルを、更新時に消去されない永続的な場所に保持する必要があります。

私はセッションを調べました。ただし、有効期限が切れており、アクティブユーザーの配列をそこに保持できません。アプリケーションオブジェクトも調べましたが、これで私のジレンマを解決できるようです。でも:

私が呼ぶと言う

String[] users = new users String[1000];  
Application['users'] = users;  

私のPage_Load()方法では、新しいユーザーをそのテーブルに格納できることを確認しますが、各ページの読み込みによってテーブルが上書きされ、常に1人のユーザーのみが表示されますが、線に沿って何かを実装するisset()ことで解決できると思います。

4

1 に答える 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

于 2012-11-04T17:58:06.520 に答える