ASPアプリケーションオブジェクト
連携して何らかの目的を実行するASPファイルのグループは、アプリケーションと呼ばれます。Applicationオブジェクトは、これらのファイルを結び付けるために使用されます。
アプリケーションオブジェクト
Web上のアプリケーションは、いくつかの目的を実行するために連携して機能する複数のASPファイルで構成されている場合があります。Applicationオブジェクトは、これらのファイルを結び付けるために使用されます。
Applicationオブジェクトは、Sessionオブジェクトと同様に、任意のページから変数を格納およびアクセスするために使用されます。違いは、すべてのユーザーが1つのアプリケーションオブジェクトを共有することです(セッションでは、各ユーザーに1つのセッションオブジェクトがあります)。
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) |