2

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

这是 Web 方法:

[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

4

1 回答 1

0

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

于 2013-07-11T10:58:37.413 回答