2

Currently I have a "Post" action in my web API controller. I first attempted having a byte[] as the only argument, hoping it would "just work". Unfortunately, it did not and it complained about formatting and conversion for form-data.

Now I have attempted to read the file content with this.Request.Content, which others seem to have had success with. Unfortunately this is including more than I really want: The content disposition, the file name, the content type, and some kind of webkit form boundary. I assume it is all of the request content.

What is the right way to do this? I have found lots of answers for ASP .NET with the FileUpload control and many articles on how to upload to a .NET web API expecting a file via POST.

Some articles mention Request.Files but it is not part of the HttpRequestMessage class.

1

1 Answer 1

4

If you're talking about multipart form data, you should have a look at our official documentation:

http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2

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

3 Comments

I don't know why this doesn't rank high in Google! I searched for "read file content asp.net web api post data" and it wasn't even on the first page. Thank you so much.
@Youssef please do you think you could help me with this question stackoverflow.com/questions/24235617/…
The link is broken

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.