Developing a Mini ASP.NET AJAX Server Centric Based Chat Application
(Page 1 of 5 )
In the old days, writing an AJAX-based web chat application often required developers to be quite familiar with client-side JavaScript programming, and to take later maintenance into consideration. In this article, Xianzhong Zhu will lead you through construction of a mini ASP.NET web chat application using the ASP.NET AJAX server centric mode.
Hitting the High Spots
As a chatting room module, its main functionalities involve: user login, ensuring authentication, sending chat messages, displaying chat messages dynamically, displaying the online user list dynamically, and so forth.
However, one of the most prominent requirements in developing a chat application lies in responding to the user in real time and displaying user information quickly so that users do not wait for a long time. Obviously, we have to display the online users' statuses in due course: neither permitting the display of offline users as if they were online, nor enabling the display of the already-online users (except for some special cases).
To achieve this goal, you must support in-time communications between the server side and the client side. This task used to be accomplished with the help of thesetIntervalorsetTimeoutfunction of JavaScript. However, with the emergence of various AJAX frameworks (especially ASP.NET AJAX) based upon ASP.NET platform, the above two functions were rarely used.
In the ASP.NET AJAX framework, the Timer control helps, when the requirements of in-time communications and not updating the whole page can be met with the combination of the UpdatePanel control and the Timer control.
In detail, the entity objects involved in constructing a web chat room module mainly include the chat users, the chat information, and the chat room. In object-oriented terms, we must abstract and encapsulate the three objects, which are utilized to achieve the related operations in the chat room module in this article.
One of the points worth noticing is that we've adopted a simple way to deal with the chat user information-it is persisted in the server side buffers, not in the databases and various files.
When the user logs into the system, he has to input his account name and password. If the current chat room does not contain this account information, he can log in using any temporary password. However, if the current chat room does contain this account information, the just-entered password and the one saved in the buffer will be compared. If they are the same, the current user can log in; otherwise, he will be prompted to re-enter the information or change to other account information. Figure 1 gives the main page of the web chat sample application.
Figure 1-the running-time snapshot for the main chatting interface

As you've seen, herein the valid users can send and receive messages, view the current online user list, and so forth.
Next: A Few Words About the Timer Control >>
More ASP.NET Articles
More By Xianzhong Zhu