0

using HttpClient を使用して、ファイルを MSMVC コントローラーにアップロードしようとしています。

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);

私のコントローラーは次のようになります:

[httpPost]
public XmlResult(HttpPostedFileBase file)
{

}

コントローラーのアクションが起動し、デバッグ ポイントを設定して、リクエストの内容を表示できます。Request.Boundry は Request.TotalBytes と同様に正しいですが、HttpPostedFileBase は null であり、Request.Files.Count() は 0 です...

私が欠けているものについてのアドバイスは素晴らしいでしょう。

4

0 に答える 0