Objek Aplikasi ASP


Sekelompok file ASP yang bekerja sama untuk melakukan beberapa tujuan disebut aplikasi. Objek Aplikasi digunakan untuk mengikat file-file ini bersama-sama.


Objek Aplikasi

Aplikasi di Web dapat terdiri dari beberapa file ASP yang bekerja sama untuk melakukan beberapa tujuan. Objek Aplikasi digunakan untuk mengikat file-file ini bersama-sama.

Objek Aplikasi digunakan untuk menyimpan dan mengakses variabel dari halaman mana pun, sama seperti objek Sesi. Perbedaannya adalah bahwa SEMUA pengguna berbagi SATU objek Aplikasi (dengan Sesi ada SATU objek Sesi untuk SETIAP pengguna).

Objek Aplikasi menyimpan informasi yang akan digunakan oleh banyak halaman dalam aplikasi (seperti informasi koneksi database). Informasi dapat diakses dari halaman manapun. Informasi juga dapat diubah di satu tempat, dan perubahan akan secara otomatis tercermin di semua halaman.

Koleksi, metode, dan acara objek Aplikasi dijelaskan di bawah ini:

Koleksi

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

Metode

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)

Acara

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)