Is it possible to upload a file, and post meta data (in the post body) at the same time in OpenRasta? and if so, do you have an example of how to do this?
Asked
Active
Viewed 222 times
1 Answers
3
I'm not sure I understand the question? When you upload a file from an html form, you get the whole form formatted as multipart/form-data, which means each field gets its own value sent alongside the files.
You only need to define your handler method as Post(string formValue, IFile file) and it'll work as is.

SerialSeb
- 6,701
- 24
- 28
-
I mean, can I post say a JSON object, and have it transcoded to an entity AND post a file at the same time, to a handler method? (PS, I'm posting using C# rather than an actual html form) – Matt Brailsford Dec 16 '10 at 14:17
-
1Well if you have two things to send they are two different things,so you should probably send both separately. THat said, (and it's highly untested, but should work), you can send the request using a multipart/form-data content type, pass the json as the first part, not forgetting its Content-Type header, and the file as the second part, as application/octet-stream. The names of the fields should map to the handler parameters, and codec resolution should just kick in – SerialSeb Dec 16 '10 at 20:48