Consider this Global.asax file. We have a static List of strings—we add to this in the Application_EndRequest method.
<%@ Application Language=
"C#" %>
<script runat=
"server">
static List<string> _endList = new List<string>();
void Application_BeginRequest(object sender, EventArgs e)
{
// Display the contents of our List.
if (_endList.Count >= 1)
{
Response.Write(
"LAST END: " + _endList[_endList.Count - 1]);
Response.Write(
" END COUNT: " + _endList.Count);
}
// End this request.
Response.End();
}
void Application_EndRequest(object sender, EventArgs e)
{
// Log end messages.
_endList.Add(
"END: " + DateTime.Now);
}
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>
LAST END: END: 5/16/2017 2:04:32 PM END COUNT: 6