Appication level event handlers in global.asax : Global.asax « ASP.Net Instroduction « ASP.NET Tutorial






<script language="VB" runat="server">

   Sub Application_Start(Sender as Object, e as EventArgs)
      Application("Time") = System.DateTime.Now
   End Sub

   Sub Application_AcquireRequestState(Sender as Object, e as EventArgs)
      Response.Write("Acquiring request session state" & "...<br>")
   End Sub

   Sub Application_AuthenticateRequest(Sender as Object, e as EventArgs)
      Response.Write("Authenticating request...<br>")
   End Sub

   Sub Application_AuthorizeRequest(Sender as Object, e as EventArgs)
      Response.Write("Authorizing request...<br>")
   End Sub

   Sub Application_PostRequestHandlerExecute(Sender as Object, e as EventArgs)
      Response.Write("Request handler executed...<br>")
   End Sub

   Sub Application_PreRequestHandlerExecute(Sender as Object, e as EventArgs)
      Response.Write("Request handler executed...<br>")
   End Sub

   Sub Application_PreSendRequestContent(Sender as Object, e as EventArgs)
      Response.Write("Receiving request content...<br>")
   End Sub

   Sub Application_PreSendRequestHeaders(Sender as Object, e as EventArgs)
      Response.Write("Receiving request headers...<br>")
   End Sub

   Sub Application_ReleaseRequestState(Sender as Object, e as EventArgs)
      Response.Write("Releasing request state...<br>")
   End Sub

   Sub Application_ResolveRequestCache(Sender as Object, e as EventArgs)
      Response.Write("Resolving request cache...<br>")
   End Sub

   Sub Application_UpdateRequestCache(Sender as Object, e as EventArgs)
      Response.Write("Updating request cache...<br>")
   End Sub

   Sub Application_Error(Sender as Object, e as EventArgs)
      Response.Write(Sender.Request.isAuthenticated & " is authenticating request...<br>")
   End Sub

   Sub Session_Start(Sender as Object, e as EventArgs)
      Response.Write("Session is starting...<br>")
   End Sub

   Sub Application_BeginRequest(Sender as Object, e as EventArgs)
      Response.Write("<b>Process</b>")
      Response.Write("Request is starting...<br>")
   End Sub

   Sub Application_EndRequest(Sender as Object, e as EventArgs)
      Response.Write("Request is ending...<br>")
   End Sub

</script>








1.6.Global.asax
1.6.1.The global.asax Application File
1.6.2.Some events don't fire with every request:
1.6.3.Global application file. (C#)
1.6.4.Appication level event handlers in global.asax
1.6.5.Global.asax file can be used to track the number of page requests made for any page.
1.6.6.Application level action sequence
1.6.7.Static application variables
1.6.8.Override string GetVaryByCustomString in Global.asax (C#)
1.6.9.Override string GetVaryByCustomString in Global.asax (VB)
1.6.10.Log exception in Global.asax (C#)
1.6.11.Log exception in Global.asax (VB)