本文介绍了WCF中的Percall和persession的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在研究WCF中的percall和persession我创建了一个客户端并在我使用两个实例管理时托管我得到相同的输出



So i am working on percall and persession in WCF i have created a client and hosted when i am working with both instance managements i am getting the same output

  [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerSession)]
public  class Service1 : IService1
   {
    private int count = 0;

       public int countlevel()
       {
           count ++;

       return count;

      }
 }










class Program
    {
        static void Main(string[] args)
        {
            ServiceReference1.Service1Client fd = new ServiceReference1.Service1Client();

             for (int i = 1; i <= 5; ++i)
        {
            Console.WriteLine(string.Format("Service called: {0} times, Return value: {1}", i, fd.countlevel()));

        }
             Console.ReadLine();
    }







但我的输出为1,1,1,1 for persession也在哪里我做错了?




But i am getting the output as 1,1,1,1 for persession also where i am doing wrong??

推荐答案


这篇关于WCF中的Percall和persession的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 17:33