title: Calling Put method in Web API with asp.net MVC as client
body: <p>I have created a Web-api with following put method</p>
  
  <p>public HttpResponseMessage Put(int id, [FromBody]DataModel model)</p>
  
  <p>in the put method i pass the object and it get updated in the database. Its working i have checked it with fiddler.</p>
  
  <p>Now in My MVC Application i call it using the following code</p>
  
  <pre><code>[HttpPost]
      public JsonResult OrderSearch(DataModel model)
      {
          UpdateOrder(model).Wait();
          if (putresult != null &amp;&amp; putresult != string.Empty)
          {
              return Json(putresult);
          }
          else
          {
              return Json("Error in getting result");
          }
      }
  
      private async Task UpdateOrder(DataModel model)
      {
         string json = JsonConvert.SerializeObject(model);
         using (var client = new HttpClient())
         {
             client.BaseAddress = new Uri(url);
             client.DefaultRequestHeaders.Accept.Clear();
             client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
  
             HttpResponseMessage response = client.PutAsync("api/values/"+ model.OrderNo,new StringContent(json)).Result;
  
             if (response.IsSuccessStatusCode)
             {
                 putresult = await response.Content.ReadAsAsync&lt;string&gt;();
  
             }
         }
  
      }
  </code></pre>
  
  <p>But the code does not hit my Put method on the service and putresult remains blank. I try to search about PutAsync usage but could not find anything so please help.</p>