I'm trying to upload a file to an MSMVC controller using the using HttpClient as so :
var client = new HttpClient();
var content = new MultipartFormDataContent(----);
var fileContent = new ByteArrayContent(photoBytes);
fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue(DispositionTypeNames.Attachment)
{
FileName = "test.jpg",
};
content.Add(fileContent);
await client.PostAsync("http://192.168.1.80/upload/upload", content);
My controller looks like :
[httpPost]
public XmlResult(HttpPostedFileBase file)
{
}
The controller action fires, I can set a debug point and example the contents of the request. The Request.Boundry is correct as is Request.TotalBytes but the HttpPostedFileBase is null and Request.Files.Count() is 0...
Any advice on what I'm missing would be great.