title: When calling an IEnumerable over a WCF Service I receive The underlying connection was closed error
body: <p>Bit of background on my question...</p>
  
  <p>I have a website and multiple console apps that access the same data layer (Linq-To-Sql) to set/get data.  The console apps run across our network and they all update the central database via WCF services.  The website is used to display the data captured by the apps data to the users.  </p>
  
  <p>My WCF services works when I'm returning simple types and when I'm returning lists of my custom objects BUT my service falls over with an 'underlying connection was closed error' whenever I try and return anything within an IEnumerable/IQueryable.   </p>
  
  <p>I thought it was possible to return IEnumerables/IQueryables over WCFs services ?  Is is possible, or, am I just configuring my service wrong ?  I'm using basicHttpBinding instead of wsHttpBinding but I'm still not 100% in what situation it is best to use the different types.</p>
  
  <p>My set-up is like this :</p>
  
  <pre><code>public class CageService : ICageRepository
  {
          public IEnumerable&lt;Cage&gt; GetAll()
          {
              var dc = new DataContext();
              return dc .GetAll();
          }
  }
  
  
  [ServiceContract]
  public interface ICageRepository : IRepository&lt;Cage&gt;
  {
      [OperationContract]
      IEnumerable&lt;Cage&gt; GetAll();
  
  }
  </code></pre>
  
  <p>Service Config :</p>
  
  <pre><code>  &lt;system.serviceModel&gt;
  
      &lt;services&gt;
        &lt;!-- Note: the service name must match the configuration name for the service implementation. --&gt;
        &lt;service name="CageService" behaviorConfiguration="CageServiceTypeBehaviors" &gt;
          &lt;host&gt;
            &lt;baseAddresses&gt;
              &lt;add baseAddress = "http://localhost/UHFWebsite/" /&gt;
            &lt;/baseAddresses&gt;
          &lt;/host&gt;
          &lt;!-- Add the following endpoint.  --&gt;
          &lt;!-- Note: your service must have an http base address to add this endpoint. --&gt;
          &lt;endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" /&gt;
  
  
          &lt;endpoint address ="" binding="basicHttpBinding" contract="Wavin.CageTracking.DataLayer.Interfaces.ICageRepository" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
  
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="CageServiceTypeBehaviors" &gt;
            &lt;!-- Add the following element to your service behavior configuration. --&gt;
            &lt;serviceMetadata httpGetEnabled="true" /&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
  
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Client config:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
        &lt;basicHttpBinding&gt;
          &lt;binding name="BasicHttpBinding_ICageRepository1" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true"&gt;
            &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
            &lt;security mode="None"&gt;
              &lt;transport clientCredentialType="None" proxyCredentialType="None"
                realm="" /&gt;
              &lt;message clientCredentialType="UserName" algorithmSuite="Default" /&gt;
  
  
            &lt;/security&gt;
          &lt;/binding&gt;
        &lt;/basicHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="http://localhost:2000/UHFServices/CageService.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ICageRepository1"
          contract="CageRepositoryClient.ICageRepository" name="BasicHttpBinding_ICageRepository1" /&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>calling code looks like:</p>
  
  <pre><code>void method()
  {
              var client = new CageRepositoryClient();
              CageListView.DataSource = client.GetAll();;
              CageListView.DataBind();
  }
  </code></pre>