Construct a homepage chat room using ASP

Source: Internet
Author: User
Having a chat room on the home page will add a lot of fun to your home page space, especially in the Intranet or LAN. However, traditional CGI Programming is a headache. With the popularity of ASP technology, making homepage chat rooms is no longer a terrible thing. Come with me step by step and have your own chat room space.
I. Principles of homepage chat rooms
1. The homepage chat room is actually not mysterious. The communication between Name members is not as direct connection as shown in, but as an intermediary through the web server. At this time, the web server is more like a big mailbox, containing a lot of messages, there are public messages that everyone can read, and there are private letters (both whispering ), it feels like they are directly communicating with each other.
The basic principles of ASP are no longer described.
The essence of constructing a chat room is its internal object Application and Session Application. The Application object corresponds to the concept of a global variable, which is created and deleted when the server is disabled. Any customer who changes it at any time will cause changes. Therefore, in the chat [room program, the Application object is used to save public information. The Session object corresponds to the local area of a customer. It is created when the customer starts to enter the site page, each customer has a unique Session ID (this ID is stored in the client Cookie, so the browser is required to accept the Cookie). Changes to Session variables are independent for each customer, in addition, it can store data on different webpages of the same customer at the same site, so Session objects are used in chat room programs to save the dedicated information of chat members, such as chat codes and whispers.
Using ASP to build a chat room fully reflects the differences between ASP and CGI programs. In CGI programs, creating a process for each client connection consumes a lot of resources. In ASP, Application objects store their own data and share a process Space. Therefore, ASP is highly efficient.
II. Construction of the basic framework
Two pages are required, one for logon and the other for main chat. Login. asp is very simple. It is a from form. After the form is submitted, the chat code and other information are sent to the Session variable Session ("name"), and then the Response is returned. redirect mainchat. asp) to the main page mainchat. asp. The main chat page consists of two frames:
Enter the words. asp page in frame1 to display the chat content. In frame2, the chat. asp page is used to send chat information.
2. Set the Application and Session object
It is natural to use Application ("show") to store public information and Session ("name") to store the chat room code. What are the private words used for storage? A clever method is used here: Use Application (Session ("name") to store whisper information! Each chat code corresponds to an Application variable. The "% = Application (Session (" name ") %> command is used on the display page to display a whisper of this code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.