I am trying to upload a file in asp.net core web api. For that i have one web app which is calling my web api.
Here is the web app code in which i am attaching the file
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "Sample");
using (var content = new MultipartFormDataContent())
{
var fileContent2 = new StreamContent(firmwareImage.InputStream);
fileContent2.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = firmwareImage.FileName
};
content.Add(fileContent2);
var result = await client.PostAsync(serviceUrl, content);
var response = await result.Content.ReadAsStringAsync();
}
}
and here is the screenshot of that attched content while debugging. Sorry for the blurry image in debug value portion.
now in web api i am receiving this request by
var files = Request.Form.Files;
but i am getting empty files always. Count is always zero. Here is the screenshot of same request.

what i am doing wrong and why i am not getting attached file in web api?
