1

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.

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

I found that my work around doesn't work either. Even with the filename in the post data, I still get Request.Files.Count as 0. So something else must be wrong although I can see the request comes in properly.
Are you using html file inputs or asp.net file controls?
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.