.NET Framework Bookmark and Share   
 index > ASMX Web Services and XML Serialization > WCF Count number of clients connected
 

WCF Count number of clients connected

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
  • Edited byv.iacono Thursday, September 10, 2009 3:01 PMclean up the extra blank lines
  • Edited byv.iacono Thursday, September 10, 2009 3:03 PM
  •  
v.iacono
Please edit your post to clean up the extra blank lines.

John Saunders
WCF is Web Services. They are not two separate things.
Use WCF for All New Web Service Development, instead of legacy ASMX or obsolete WSE
Use File->New Project to create Web Service Projects
John Saunders

You can use google to search for other answers

Custom Search

More Threads

• Updating 3 database server using Webservices
• Differences in WSDL between web service versions.
• How to develop ASP.NET application?
• Writing Comments through C# Xml Serialization
• OneWay=true IS not working
• XML Transport Via SOAP without Web server?
• Visual Studio 2005 Webservices error
• Error Creating Control - CreateUserWizard1
• How to disable SOAPAction header validation?
• How to know if client loses connection, etc