hi,
i want count number of client connected to my service. But Session_start never fired... why ???
this global.asax
void Application_Start(object sender, EventArgs e)
{ //ApplicationCache.loadApplicationCache();
ApplicationCache.DoStatistics();
Application["TOTAL_SESSIONS"] = 0;
}
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
//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)
{
// Code that runs when a new session is started
lock (Application)
{
int i = (int)Application["TOTAL_SESSIONS"];
i++;
Application["TOTAL_SESSIONS"] = i;
}
}
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.
lock (Application)
{
int i = (int)Application["TOTAL_SESSIONS"];
i--;
Application["TOTAL_SESSIONS"] = i;
}
}
this the web method that get number of clients
/// <summary>/// Restituisce numero utenti collegati
/// </summary>
[WebMethod(Description = "Return number of connected clients")]
public int Clients()
{
return (int)Application["TOTAL_SESSIONS"];
}
i always recived 0 .... why ???
DOTT