title: HttpClient fails on certain requests
body: <p>I can make some requests to the web service and they work fine - However this one returns the error message. </p>
  
  <ul>
  <li>"One or more errors occurred"  </li>
  <li>"The underlying connection was closed:An unexpected error occurred on a receive." </li>
  <li>"Unable to read data from    the transport connection: An existing
  connection was forcibly closed    by the remote host."</li>
  </ul>
  
  <p>I've debugged the web service and it returns the correct JSON. </p>
  
  <p>Below is the code I use to call the web service. I have tried Async / Await but it didn't make an difference. </p>
  
  <pre><code> public static string PostURL(string uri, List&lt;KeyValuePair&lt;string, string&gt;&gt; pairs)
      {
          try
          {
              var content = new FormUrlEncodedContent(pairs);
              var httpClient = new HttpClient();
              var response = httpClient.PostAsync(uri, content).Result;
              if (response.IsSuccessStatusCode)
                  return response.Content.ReadAsStringAsync().Result.ToString();
              else
                  return "Failed";
          }
          catch(AggregateException e)
          {
              return e.Message;
          }
  
      }
  </code></pre>
  
  <p>This is the bit of code calling the HttpClient Post</p>
  
  <pre><code>   public ActionResult JobDetails()
      {
          var response = WebServicePost.PostURL(WebServicePost.Uri + "JobService.svc/GetJob/", new List&lt;KeyValuePair&lt;String, String&gt;&gt; 
              {
                  new KeyValuePair&lt;string, string&gt;("JobID", "46"),
                  new KeyValuePair&lt;string, string&gt;("CompanyCode", System.Web.HttpContext.Current.Request.Cookies["CompanyCode"].Value)
              });
          List&lt;Job&gt; list = (List&lt;Job&gt;)JsonConvert.DeserializeObject(response.ToString(), typeof(List&lt;Job&gt;));
          return View(list);
      }
  </code></pre>
  
  <p>This then populates the a DataTable on the front end. </p>
  
  <p>The call to the web service is the following. </p>
  
  <pre><code>  public List&lt;Job&gt; GetJob(Stream streamData)
      {
          dynamic jObject = streamReader.ConvertToDynamicJsonObject(streamData);
          int jobID = int.Parse(jObject["JobID"]);
          using (var session = NHibernateHelper.OpenSession())
          {
              using (var transaction = session.BeginTransaction())
              {
                  try
                  {
                      var query = session.QueryOver&lt;Job&gt;().Where(x =&gt; x.JobID == jobID).List();
                      return query.ToList();
                  }
                  catch (Exception e)
                  {
                      Logger.log("Exception at GetJob", e.Message);
                      return null;
  
                  }
              }
          }
      }
  </code></pre>
  
  <p>Does anyone know why this might be happening?</p>