This should be very trivial but for reason can't find it. I'm posting some binary data to a form in ASP.NET as multipart/form-data and I can see that the request is receive by looking at Request.InputStream :
-------------------------------7cf2a327f01ae Content-Disposition: form-data; name="DeviceID1"
Some binary data
-------------------------------7cf2a327f01ae Content-Disposition: form-data; name="DeviceID2"
Some binary data ...
However I can't find how I can retrieve each part as part of the Request.Form (or Request.Params) collection. What could be wrong? One work around is to use a filename then retrieve from Request.Files but I wonder what is the proper way of getting the content. Thanks.
Request.Files
是检索发布到服务器的二进制数据的唯一方法。
I found that one problem was the line break and that the request should be terminated with a proper separator like this:
-------------------------------7cf2a327f01ae
Content-Disposition: form-data; name="DeviceID1"
Some binary data
-------------------------------7cf2a327f01ae
Content-Disposition: form-data; name="DeviceID2"
Some binary data
-------------------------------7cf2a327f01ae
Now the keys appear in Request.Form however this collection is of type string so I decided to use the filename and then get from Request.Files. Or I could parse the entire request content completely manually.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.