title: Why can't I access core webapi from xamarin forms?
body: <p>I have a standard .net2.0 Xamarin forms project that works flawlessly with the asp.net core webapi as long as I start the api from a different VS2017 instance.</p>
  
  <p>If I include it in the Xamarin solution like this:</p>
  
  <p><a href="https://i.stack.imgur.com/4MfDc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4MfDc.png" alt="enter image description here"></a></p>
  
  <p>It erros out with: Message  "Cannot access a disposed object.\nObject name: 'System.Net.Sockets.NetworkStream'."    string</p>
  
  <p>This is the http call:</p>
  
  <pre><code>public static async Task&lt;string&gt; PostDataAsync(string url, string json, string baseUrl)
          {
              try
              {
                  var response = await client.PostAsync(baseUrl + url, new StringContent(
                      json,
                      Encoding.UTF8,
                      "application/json"));
  
                  if (response.IsSuccessStatusCode)
                  {
                      string result = await response.Content.ReadAsStringAsync();
                      return result;
                  }
                  else
                  {
                      return response.ReasonPhrase;
                  }
              }
              catch (Exception e)
              {
                  return null;
              }
          }
  </code></pre>
  
  <p>It hits the PostAsync methods, the parameters are correct, but goes immediately to "Catch" with the error mentioned above.</p>
  
  <p>Any ideas?</p>