Search code examples
c#.netwcfwcf-data-services

C# - How to parse http header multipart


I created a WCF Rest service and I am reading content sent by multipart/form data. However I get the contentdisposition and extra information. Is there a way to parse it like using HttpContext. I dont want dependency with asp...

If possible no use of external libraries, thirdparty dlls, etc... Unless its simple and consistent code I can implement.


Solution

  • In case of parsing multipart data you should use some library/class or do it manually. There is no built-in functionality. Parser is pretty easy. But you can reuse some parser classes already written.

    1. Try following project (MIT license) and file HttpMultipartParser.cs from this project:

      https://bitbucket.org/lorenzopolidori/http-form-parser/src

    2. http://multipartparser.codeplex.com/

      http://multipartparser.codeplex.com/SourceControl/changeset/view/69709#458003