When I have a web API method with a signature like this:
public async void Post()
I get an exception that says:
"Unexpected end of MIME multipart stream. MIME multipart message is not complete."
when reading the multipart data with this line:
await Request.Content.ReadAsMultipartAsync(provider);
However when I change the method into:
public async Task<Boolean> Post()
returning a Task with any type (in this case bool) everything works fine.
Comments: The reason is that when your action just returns "void" then we don't know that the action is still processing the request and so we complete it which leads to the error you see. By returning a Task we can track that the action is still doing things and so we don't continue until it is done. Because it is using Tasks we of course don't block any threads waiting but we have to know when the action is complete. You can also do this (just returning Task and not Task<T>): public async Task Post() Hope this helps, Henrik
public async void Post()
I get an exception that says:
"Unexpected end of MIME multipart stream. MIME multipart message is not complete."
when reading the multipart data with this line:
await Request.Content.ReadAsMultipartAsync(provider);
However when I change the method into:
public async Task<Boolean> Post()
returning a Task with any type (in this case bool) everything works fine.
Comments: The reason is that when your action just returns "void" then we don't know that the action is still processing the request and so we complete it which leads to the error you see. By returning a Task we can track that the action is still doing things and so we don't continue until it is done. Because it is using Tasks we of course don't block any threads waiting but we have to know when the action is complete. You can also do this (just returning Task and not Task<T>): public async Task Post() Hope this helps, Henrik