zimcoder Level: VB Lord

 Registered: 27-10-2003 Posts: 225
|
Re: when and how many times the application_onstart fire in asp.net ?
The Application_Start Event fires only once in an ASP.NET application. The handling of the Event is within the Global asax file. Each ASP.NET Application can contain an optional Global asax file.. This file is compiled once on the first invocation of the application. The Global asax file is compiled into a .NET class whose base class is the HttpApplication class.
This event will not file again during the lifecycle of the application unless
1)The Application is restarted or
2) Modifications are carried out on the Global asax file, in Which case the Global asax file is recompiled and the Application_start event fired when the first request is made.
Here is a script example in which the number of visitors is counted and display using this Event,
<script language="C#" runat="server">
void Application_Start(object sender, EventArgs e) {
Application.Lock()
Application("Visitors") += 1
Application.UnLock()
Context.Response.Write(Application("Vistors"))
}
</script> |
____________________________
BrainBench ADO.NET and ASP.NET Certified Developer
 
|