MultipartFormDataStreamProvider
マルチパートリクエストを処理するために使用していました。
アップロードしたファイルをディスク ファイルではなくメモリに保存したいので、コードを変更してMultipartMemoryStreamProvider
. provider.FormData
ファイルの読み込みは正常に機能しているようですが、で利用できた他のフォーム値にアクセスできなくなりましたMultipartFormDataStreamProvider
。誰かがこれを行う方法を教えてもらえますか?
Fiddler によってキャプチャされた生のリクエスト:
POST http://myserver.com/QCCSvcHost/MIME/RealtimeTrans/ HTTP/1.1
Content-Type: multipart/form-data; boundary="XbCY"
Host: na-w-lxu3
Content-Length: 1470
Expect: 100-continue
Connection: Keep-Alive
--XbCY
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=PayloadType
X12_270_Request_005010X279A1
--XbCY
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=ProcessingMode
RealTime
--XbCY
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=PayloadID
e51d4fae-7dec-11d0-a765-00a0c91e6fa6
--XbCY
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=TimeStamp
2007-08-30T10:20:34Z
--XbCY
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=SenderID
HospitalA
--XbCY
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=ReceiverID
PayerB
--XbCY
Content-Type: text/plain; charset=utf-8
Content-Disposition: form-data; name=CORERuleVersion
2.2.0
--XbCY
Content-Disposition: form-data; name=Payload; filename=276_5010.edi
ISA*00*~SE*16*0001~GE*1*1~IEA*1*191543498~
--XbCY--
私のコントローラーコード:
string payload = null;
NameValueCollection nvc = null;
string fname = null;
StringBuilder sb = new StringBuilder();
sb.AppendLine();
foreach (StreamContent item in provider.Contents)
{
fname = item.Headers.ContentDisposition.FileName;
if (!String.IsNullOrWhiteSpace(fname))
{
payload = item.ReadAsStringAsync().Result;
}
else
{
nvc = item.ReadAsFormDataAsync().Result;
}
}