I'd like to post a file to my webapi. It's not the problem but:
- I don't want to use javascript
- The file must be received and saved synchronously
I would like my action to look like this:
public void Post(byte[] file) { }
or:
public void Post(Stream stream) { }
I want to post file from code similiar to this (of course, now it doesn't work):
<form id="postFile" enctype="multipart/form-data" method="post"> <input type="file" name="file" /> <button value="post" type="submit" form="postFile" formmethod="post" formaction="<%= Url.RouteUrl("WebApi", new { @httpRoute = "" }) %>" /> </form>
Any suggestions will be appreciated
I think action should be like
The simplest example would be something like this
There is no synchronous version of
ReadAsMultipartAsync
so you are better off playing along.UPDATE:
If you are using IIS server hosting, you can try the traditional way: