Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi guys i have problem with my WCF service
i create service run on wsHttpBinding and use instance per-session
it's small service that count number automatic

service code:

C#
static int m_counter = 0;
public string MyMethod()
{
  
    m_counter++;

    return m_counter;

}


my problem it's when i re-connect i get the last number again not start from 0 but session id changed !

client code:

C#
static void Main(string[] args)
 {
     for (int i = 0; i < 5; i++)
     {
         Service1Client proxy = new Service1Client();
         proxy.Open();
         string sessionid = proxy.InnerChannel.SessionId;
         Console.WriteLine("Session id is: " + sessionid);
         Console.WriteLine("Data is: " + proxy.MyMethod());
         proxy.Close();
     }
     Console.ReadKey(true);
 }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900