title: how to call HttpPut on web.api controller from C# httpclient with .net 4.6
body: <p>I am currently building a web.api for a pizzaria, C#, and .NET 4.6<br>
  I have a C# client that wants to select a pizza from code.. the pizza is in json.  </p>
  
  <pre><code>{"id":1,"Name":"Magariatha"}  
  </code></pre>
  
  <p>I am calling from an asp.net site hosted in iis express, I dont get through.
  If I call from Fiddler, the call passes through, and the pizza is selected and can get ordered ;-)</p>
  
  <p>My PizzaController looks like:</p>
  
  <pre><code>public HttpResponseMessage Put(Pizza pizza)
  {
     string pizzaApi = "Api/Pizza/";   
     var handler = new WebRequestHandler() {  
         AllowAutoRedirect = false,  
         UseProxy = false };
  
     using( var client = new HttpClient(handler)) {  
        client.BaseAdresse = new Uri("http://localhost:12345");   
        var media = new MediaTypeWithQualityHeaderValue("application/json");  
        client.DefaultRequestHeaders.Accept.Add(media);  
  
       // so far so good, but the trouble starts in the next line...
       return client.PutAsJsonAsync(pizzaApi, pizza).
                ContinueWith(x =&gt; x.Result.EnsureSuccessStatusCode)).Result;  
    } // end using
  } // end put
  </code></pre>
  
  <p>It appears that something get disposed in the call to putasjson, before the server gets accessed. But I cannot figure out why.. I get the message:</p>
  
  <pre><code>Exception thrown: 'System.ObjectDisposedException' in System.Net.Http.dll
  </code></pre>