title: C# unable to assign cookiecontainer to asmx web service client
body: <p>I'm attempting to connect to a asmx web service in C# using visual studio 2012 express.</p>
  
  <p>The documentation says to assign a cookiecontainer to the web service like follows:</p>
  
  <pre><code>using System.Web.Services.Protocols;    /// using appropriate references
  using System.Net;
  using System.Net.Http;
  
  //   Create an instance of the Web Service and assign in
  //   a cookiecontainer to preserve the validated session
  
  ServiceRef.WSClient wsClient = new ServiceRef.WSClient();
  
  CookieContainer cookieJar = new CookieContainer();
  wsClient.CookieContainer = cookieJar;
  </code></pre>
  
  <p>But, that results in error:</p>
  
  <pre><code>'WebServiceTest.ServiceRef.WSClient' does not contain a definition 
  for 'CookieContainer' and no extension method 'CookieContainer' 
  accepting a first argument of type 'WebServiceTest.ServiceRef.WSClient' 
  could be found (are you missing a using directive or an assembly 
  reference?)
  </code></pre>
  
  <p>I've tried adding "allowCookies" to app.config.  That doesn't seem to work; calling ws methods that require being logged in (having a cookie set) fail.  Fail means I get a message about a problem with the xml they return (they're returning some non-xml error presumably).</p>
  
  <p>I'm totally new to C#, SOAP based web services, and visual studio, but I've seen numerous code examples that use code exactly like mine.  For example:</p>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/system.web.services.protocols.httpwebclientprotocol.cookiecontainer.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.web.services.protocols.httpwebclientprotocol.cookiecontainer.aspx</a></p>
  
  <p><a href="http://megakemp.com/2009/02/06/managing-shared-cookies-in-wcf/" rel="nofollow">http://megakemp.com/2009/02/06/managing-shared-cookies-in-wcf/</a></p>