I am just trying to write a multipart parser but things getting complicated and want to ask if anyone knows of a ready parser in C#!
Just to make clear, I am writing my own "tiny" http server and need to pars multipart form-data too!
Thanks in advance, Gohlool
Check out the new MultipartStreamProvider and its subclasses (i.e. MultipartFormDataStreamProvider). You can create your own implementation too if none of the built in implementations are suitable for you use case.
With Core now you have access to a IFormCollection by using HttpContext.Request.Form.
Example saving an image:
I've had some issues with parser that are based on string parsing particularly with large files I found it would run out of memory and fail to parse binary data.
To cope with these issues I've open sourced my own attempt at a C# multipart/form-data parser here
See my answer here for more information.
I open-sourced a C# Http form parser here.
This is slightly more flexible than the other one mentioned which is on CodePlex, since you can use it for both Multipart and non-Multipart
form-data
, and also it gives you other form parameters formatted in aDictionary
object.This can be used as follows:
non-multipart
multipart
I had a similar problem that i recently solved thanks to Anthony over at http://antscode.blogspot.com/ for the multipart parser.
Uploading file from Flex to WCF REST Stream issues (how to decode multipart form post in REST WS)