Question

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.

Was it helpful?

Solution

Request.Files is the only way to retrieve the binary data that's posted to the server.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top