webservice不可能引用到客户端的session,除非你把Session["userid"]做为一参数传递给它。

解决方案 »

  1.   

    你去看程序员大本营合订本 那里面写着session怎样在 虚拟目录和websevice通用。具体方法我也记不清了,但是肯定可以。
      

  2.   

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemWebServicesWebMethodAttributeClassEnableSessionTopic.asp
      

  3.   

    按照 这种说法
    就是一个 Cookie容器的问题了。。但是加入我的客户段不是浏览器的话
    怎么获取浏览器的CookieContainer。。可是不知道怎么获取。
      

  4.   

    类似地在PROXY CLASS的CTR中
    youws MyGame = new yourws();
     MyGame.CookieContainer =new System.Net.CookieContainer(); // Session Cookie
      

  5.   

    是的啊 不过这样创建了 一个新的CookieContainer 
    而我的想法是 根浏览器 公用Session
      

  6.   

    ServerUsage su = new ServerUsage();
              CookieContainer cookieJar;      // Check to see if the cookies have already been saved for this session.
          if (Session["CookieJar"] == null) 
            cookieJar= new CookieContainer();
              else
           cookieJar = (CookieContainer) Session["CookieJar"];        // Assign the CookieContainer to the proxy class.
            su.CookieContainer = cookieJar;      // Invoke an XML Web service method that uses session state and thus cookies.
          int count = su.PerSessionServiceUsage();               // Store the cookies received in the session state for future retrieval by this session.
          Session["CookieJar"] = cookieJar;          // Populate the text box with the results from the call to the XML Web service method.
              SessionCount.Text = count.ToString();
      

  7.   

    In order to store session state in the ASP.NET HttpSessionState object, the XML Web service must inherit from WebService and a WebMethodAttribute applied to the XML Web service method, setting the EnableSession property to true. If session state is not needed for an XML Web service method, then disabling it may improve performance.
      

  8.   

    Web Service里调用不了session,必须将Session值与其他要传递的值组成字符串一起传入webmethod,然后将他分开后再调用;若要更改Session,可在Web Service的返回函数中处理。
      

  9.   

    Session["userid"] = "testvalue";改成如下模式试试:HttpContext.Current.Session["userid"] = "testvalue";
      

  10.   

    http://developer.ccidnet.com/pub/disp/Article?columnID=322&articleID=32324&pageNO=1解析WEB SERVICE中的状态管理 (1)http://developer.ccidnet.com/pub/article/c322_a32324_p2.html
    解析WEB SERVICE中的状态管理 (2)http://developer.ccidnet.com/pub/article/c322_a32324_p3.html
    解析WEB SERVICE中的状态管理 (3)