0

I am using Instancing mode as PerSession - If a client makes multiple request for a given method - o/p should be incremented as per below code snippet b/c Instancing mode is PerSession,

However I am always getting value as 1 for every call, ideally it should be incremented.

Let me know what I am missing

Thanks in advance...

Server

[ServiceContract]
public interface IServer
{
 [OperationContract]
  int GetData();
}

[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
public class Service1 : IServer
{
  int count = 0;
  public int GetData()
   {
     count++;
     return count;
   }
}

Client

ServiceReference1.IServer obj = new ServiceReference1.ServerClient();
Console.WriteLine(obj.GetData());
Console.WriteLine(obj.GetData());
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Amit
  • 3,358
  • 9
  • 34
  • 48

1 Answers1

0

what is the binding you have ? basicHttpBinding does not support PerSession instance mode it defaults to PerCall.

If you have basicHttpBinding change that to wsHttpBinding and try.

Suhumar
  • 355
  • 3
  • 13
  • Thx for reply, however I am using binding="wsHttpBinding" – Amit Jan 20 '11 at 14:03
  • If that is the case the above code works fine for me. It prints 1 2 and 3. The problem should definitely be with some configuration setting. Sometimes though you may set the binding to wsHTTP it may default to basic for some scenario's.. – Suhumar Jan 20 '11 at 15:01
  • hi Suhumar, could you pls let me know the steps that you followed to get above mentioned o/p, also specify the projects that you had taken.. Thanks in advance... – Amit Jan 25 '11 at 06:28