ASP Application Object
กลุ่มของไฟล์ ASP ที่ทำงานร่วมกันเพื่อดำเนินการบางอย่างเรียกว่าแอปพลิเคชัน วัตถุ Application ใช้เพื่อผูกไฟล์เหล่านี้เข้าด้วยกัน
แอพลิเคชันวัตถุ
แอปพลิเคชันบนเว็บอาจประกอบด้วยไฟล์ ASP หลายไฟล์ที่ทำงานร่วมกันเพื่อดำเนินการตามวัตถุประสงค์บางประการ วัตถุ Application ใช้เพื่อผูกไฟล์เหล่านี้เข้าด้วยกัน
วัตถุแอปพลิเคชันใช้เพื่อจัดเก็บและเข้าถึงตัวแปรจากหน้าใดก็ได้ เช่นเดียวกับวัตถุเซสชัน ความแตกต่างคือ ผู้ใช้ทั้งหมดแชร์ออบเจ็กต์แอปพลิเคชันหนึ่งรายการ (ด้วยเซสชันจะมีออบเจ็กต์เซสชันหนึ่งรายการสำหรับผู้ใช้แต่ละราย)
ออบเจ็กต์แอปพลิเคชันเก็บข้อมูลที่จะใช้โดยหลาย ๆ เพจในแอปพลิเคชัน (เช่นข้อมูลการเชื่อมต่อฐานข้อมูล) ข้อมูลสามารถเข้าถึงได้จากหน้าใดก็ได้ ข้อมูลสามารถเปลี่ยนแปลงได้ในที่เดียว และการเปลี่ยนแปลงจะมีผลกับทุกหน้าโดยอัตโนมัติ
คอลเล็กชัน วิธีการ และเหตุการณ์ของออบเจ็กต์ Application ได้อธิบายไว้ด้านล่าง:
ของสะสม
Collection | Description |
---|---|
Contents | Contains all the items appended to the application through a script command |
StaticObjects | Contains all the objects appended to the application with the HTML <object> tag |
วิธีการ
Method | Description |
---|---|
Contents.Remove | Deletes an item from the Contents collection |
Contents.RemoveAll() | Deletes all items from the Contents collection |
Lock | Prevents other users from modifying the variables in the Application object |
Unlock | Enables other users to modify the variables in the Application object (after it has been locked using the Lock method) |
กิจกรรม
Event | Description |
---|---|
Application_OnEnd | Occurs when all user sessions are over, and the application ends |
Application_OnStart | Occurs before the first new session is created (when the Application object is first referenced) |