WCF会话问题 [英] Problem with WCF session
本文介绍了WCF会话问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好我的WCF服务有问题
i创建服务在wsHttpBinding上运行并使用每个会话实例
这是自动计数的小服务
服务代码:
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:
static int m_counter = 0;
public string MyMethod()
{
m_counter++;
return m_counter;
}
我的问题是当我重新连接时我再次获得最后一个号码而不是从0开始但是会话ID改变了!
客户代码:
my problem it's when i re-connect i get the last number again not start from 0 but session id changed !
client code:
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);
}
推荐答案
这篇关于WCF会话问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文