は私がHttpRequest.Formにアクセスしてみてください(データ用マルチパート)このポストWeb APIメソッド(非同期以外)でパラメータを受け入れる方法はありますか?
おかげ
public string Post()
{
try
{
var httpRequest = HttpContext.Current.Request;
if (httpRequest.Files.Count < 1)
{
return "n";
}
foreach (string file in httpRequest.Files)
{
string downloadedImagesPath = ConfigurationManager.AppSettings["DownloadedImagesPath"];
var postedFile = httpRequest.Files[file];
var filePath = HttpContext.Current.Server.MapPath(Path.Combine(downloadedImagesPath, postedFile.FileName));
postedFile.SaveAs(filePath);
}
}
catch (Exception ex)
{
return "e";
}
return "k";
}
'Multipart/Form-Data'リクエストにはパラメータを設定することはできません。あなたがする必要があるのは、リクエストの本体のパラメータを渡して、それらを解析することです。これをオンラインで行う方法の例があります:https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/sending-html-form-data-part-2#reading-form-制御データ – GBreen12
ありがとう、答えを出して、それを受け入れる – RollRoll