从多部分/表单数据POST中读取

时间:2019-03-15 02:30:24

标签: c# post

我正在尝试使用C#阅读PDF文件。该消息将以多部分/表单数据POST的形式出现。示例如下,但是无论我如何尝试,我都无法读取字节。

我正在阅读钥匙;

               string[] keys = Request.Form.AllKeys;
                for (int i = 0; i < keys.Length; i++)
                {
                    w.WriteLine(keys[i] + ": " + Request.Form[keys[i]] + "<br>");
                }

输出;

transactionId: 6350<br>
orderId: 314053<br>
orderStatus: Ready<br>
customerReferenceId: 7<br>
filename: Bk-314053-tx6350-Mess.pdf<br>
fileformat: pdf<br>

但是很难加载pdf二进制数据。

    ------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="transactionId"

17
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="orderId"

40274
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="orderStatus"

Ready
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="paymentId"

3
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="paymentAmount"

34.95
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="customerReferenceId"

7
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="referenceId"

11223344
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="referenceText"

I am reference text
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="filename"

Bk-40274-tx17-Mess.pdf
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="fileformat"

pdf
------------d0f32ac86c8249c9aa562c1fcfbfeb66
Content-Disposition: form-data; name="file"; filename="Bk-40274-tx17-Mess.pdf"
Content-Type: application/pdf

<BINARY PDF BYTES DATA>

0 个答案:

没有答案