<%@ Import Namespace="System.IO"%>
<%@ Application Language="VB" %>
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Application("OnlineNow") = 0
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
Application("OnlineNow") = Nothing
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Dim StrWer As StreamWriter
StrWer = New StreamWriter(Server.MapPath("log/") & "thaicreate.txt", True)
StrWer.WriteLine(Date.Now & " - The Application Error")
StrWer.Close()
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
Application.Lock()
Application("OnlineNow") = Application("OnlineNow") + 1
Application.UnLock()
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
Application("OnlineNow") = Application("OnlineNow") - 1
Application.UnLock()
End Sub
</script>
AspNetGlobal.aspx
<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = Application("OnlineNow") & " Online"
End Sub
</script>
<html>
<head>
<title>ThaiCreate.Com ASP.NET - Global.asax</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label id="lblText" runat="server"></asp:Label><br />
</form>
</body>
</html>