Application State can save user counts.More information click link and get more info.
<%@ Application Language="C#" %>
<script runat="server">
public static int count = 0;
void Application_Start(object sender, EventArgs e)
{
Application["TotalUsers"] = count;
Application["OnlineUsers"] = count;
}
void Application_End(object sender, EventArgs e)
{
// Application["users"] = -1;
}
void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
string message = "Error occurred in - " + Request.Url.ToString() + "and error message is - "
+ exception.Message + " Stack Trace - " + exception.StackTrace.ToString();
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
count++;
Application["OnlineUsers"] = count;
Application["TotalUsers"] = count ;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
// count--;
Application.Lock();
Application["OnlineUsers"] = count - 1;
Application.UnLock();
}
</script>
No comments:
Post a Comment