I do not understand why in the controller productId comes 0. Here is the controller:
[Route("Test/Post")] public async Task<ActionResult> PostTest(IFormFile files, int productId) { if (ModelState.IsValid) { string path = null; if (files != null) { path = "/ProductImages/" + files.FileName; using (var fileStream = new FileStream(_env.WebRootPath + path, FileMode.Create)) { await files.CopyToAsync(fileStream); } return Ok(productId); } else return BadRequest("Model is not valid"); } else return BadRequest("Model is not valid"); } I try:

filesfornullafter accessingfiles.FileNameis a bit late. - Igorfilescome null, why? - Vitaly Shebanits