title: How to send IFormFile to Web API as part of ViewModel object
body: <p>I have .NET Core Web App with the following controller: </p>
  
  <pre><code>    [HttpPost]
      public async Task&lt;IActionResult&gt; Update(StudentDetailsViewModel vm)
      {           
          var tokenNo = HttpContext.Session.GetString("Token");
          vm.ID = Convert.ToInt32(HttpContext.Session.GetString("StudentId"));
  
          HttpClient client = new HttpClient();
          client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenNo);
          client.DefaultRequestHeaders.Accept.Clear();
          client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
  
          var putStudentUrl = _appSettings.Value.Apis.GSRTCApi.Url + _appSettings.Value.Apis.GSRTCApi.StudentsEndpoint + vm.ID;
  
          var settings = new JsonSerializerSettings();
  
          var stringData = JsonConvert.SerializeObject(vm); 
  
          var contentData = new StringContent(stringData, Encoding.UTF8, "application/json");
  
          var response = await client.PutAsync(putStudentUrl, contentData); // contentData);
  
  
          return RedirectToAction("Index", "Home");
      }
  </code></pre>
  
  <p>The controller calls my Web API and everything works fine until I upload a file through my html form. When this happens the file is picked up in the IFormFile property of the StudentDetailsViewModel on the client side but when the API call is made the whole object is null. The API controller is: </p>
  
  <pre><code>[HttpPut("{id}")]
  public async Task&lt;IActionResult&gt; Put(int? id, [FromBody]StudentViewModel student)
  {
      // API operations here
  } 
  </code></pre>
  
  <p>My suspicion is that I am not serializing the StudentDetailsViewModel object properly since I have a property IFormFile, which is an interface. However, I am not sure exactly how I need to customize the Json.Newsoft object. </p>