본문 바로가기
Language(언어)/ASP

ASP Application 개체 OnStart

by 대학교닷컴 2013. 12. 6.


OnStart

 

영문
The OnStart event occurs before the start of any new session by a user (i.e., before the Application object is first referenced). The signal of this event will run a handler script in the Global.asa file, if the script exist.

The Application_OnStart event occurs before the beginning of any user session. The only built-in ASP objects available from within the OnStart event handler are Server and Application. The Application_OnStart event is simply a subroutine with a reserved name that is placed within the Global.asa file. It contains any script that you wish to run before the first user session. For example, you could use the Session.Timeout property to automatically end an idle user session after 10 minutes.

Note that you must declare the scripting language used to code the event script on the first line of the Global.asa file.

번역본
OnStart 이벤트는 사용자가 새로운 세션 (즉, Application 개체가 먼저 참조되기 전에)이 시작되기 전에 발생합니다.스크립트가 존재한다면 해당 이벤트의 신호는 Global.asa 파일에서 핸들러 스크립트를 실행합니다.

Application_OnStart 이벤트는 사용자 세션의 시작 전에 발생합니다.OnStart 이벤트 처리기 내에서 사용할 수있는 유일한 내장 ASP 개체는 서버 및 응용 프로그램입니다.Application_OnStart 이벤트는 단순히 Global.asa 파일 내에 배치됩니다 예약된 이름을 가진 서브루틴이다. 그것은 당신이 첫 번째 사용자 세션 전에 실행하고자하는 스크립트가 포함되어 있습니다. 예를 들어, 자동 십분 후에 유휴 사용자 세션을 종료하려면 Session.Timeout 속성을 사용할 수 있습니다.

여러분이 Global.asa 파일의 첫 줄에 이벤트 스크립트를 코드에 사용되는 스크립팅 언어를 선언해야합니다.

예제

Code:
-------------------Global.asa--------------------------
<script Language="VBScript" RUNAT=Server>
Sub Application_OnEnd()
End Sub

Sub Application_OnStart()
     Application("NumSession") = 0
     Application("NumVisited") = 0
     Session.Timeout = 10
End Sub

Sub Session_OnEnd()
     Application("NumSession") = Application("NumSession") - 1
End Sub

Sub Session_OnStart()
     Application("NumSession") = Application("NumSession") + 1
     Application("NumVisited") = Application("NumVisited") + 1
End Sub
</script>
   
-------------------File1.asp----------------------------
Response.Write "You are " & Application("NumSession") & " of " & Application("NumVisited") & " users."
 
Output:
You are 1 of 1 users.

댓글