I am sending multipart form-data to my WebApi controller. The content that interests me includes both the image and a different value than the image. I cannot read the image without problems, but I cannot figure out how to read the username part (with andy as the value). This is not in the FormData property of the provider. How can i get it?
Multi-format form data
------------ei4KM7KM7ae0GI3Ef1gL6ei4ae0ae0
Content-Disposition: form-data; name="Filename"
image.jpg
------------ei4KM7KM7ae0GI3Ef1gL6ei4ae0ae0
Content-Disposition: form-data; name="username"
andy
------------ei4KM7KM7ae0GI3Ef1gL6ei4ae0ae0
Content-Disposition: form-data; name="Filedata"; filename="image.jpg"
Content-Type: application/octet-stream
------------ei4KM7KM7ae0GI3Ef1gL6ei4ae0ae0
Content-Disposition: form-data; name="Upload"
Submit Query
------------ei4KM7KM7ae0GI3Ef1gL6ei4ae0ae0--
Controller code
string root = System.Web.HttpContext.Current.Server.MapPath("~/App_Data");
MultipartFormDataStreamProvider provider = new MultipartFormDataStreamProvider(root);
var task = request.Content.ReadAsMultipartAsync(provider).ContinueWith<HttpResponseMessage>(o =>
{
...
}
source
share