从Webservice调用方法时,SessionId发生了更改

时间:2013-07-10 17:50:13

标签: c# asp.net

我有两个项目。其中一个有WebService(asmx),第二个使用WebService作为参考。

这是WebMethod:

[WebMethod(EnableSession = true)]
public int GetDocCount(CompressedData data)
{
    if (Session[Settings.cStrSessionUserLogin] == null)
    {
        return 0;   
    }
    string xmlString = EncoderUtil.Decompress(data);
    SortFilterSet sfs = (SortFilterSet)XmlUtil.Deserialize(typeof(SortFilterSet), xmlString);
    Session[Settings.cStrSessionSortFilterSet] = sfs;
    Session[Settings.cStrSessionOrderCodeList] = null;      

    return Database.GetOrderCount((List<RequestorInfo>)Session[Settings.cStrSessionRequestorList], sfs.FilterSet, sfs.SearchPattern);
}

当我创建客户端时,我有一个sessionid,但每当我调用WebMethod时,我都会看到WebMethod中的SessionId更改(我可以通过Debug看到)

MyWebServiceSoapClient client = new MyWebServiceSoapClient();
int countDocs = client.GetDocCount(data);

为什么我在WebMethod中看到一个新的SessionId,如何避免这种情况并获得原始的SessionId?

编辑: WebMethod Session.Count内部始终为0

1 个答案:

答案 0 :(得分:0)

我删除了WebService引用,然后在项目中插入了MyWebServiceSoapClient.asmx和MyWebServiceSoapClient.cs。现在我再也没有得到新的SesseionId了。