【发布时间】:2012-08-28 17:01:15
【问题描述】:
有没有办法在 ASP.Net Web API 中同步处理上传到控制器的上传文件?
我已经尝试过 Microsoft 提出的 here 流程,它的工作原理与描述的一样,但我想从 Controller 方法返回 Task 以外的其他内容,以匹配我的 RESTful API 的其余部分。
基本上,我想知道是否有任何方法可以使这项工作:
public MyMugshotClass PostNewMugshot(MugshotData data){
//get the POSTed file from the mime/multipart stream <--can't figure this out
//save the file somewhere
//Update database with other data that was POSTed
//return a response
}
再次,我已经使异步示例工作,但我希望有一种方法可以在响应客户端之前处理上传的文件。
【问题讨论】:
-
当您在
asyncASP.NET 方法中await时,您不会响应客户端。仅当所有async操作完成时才会发送客户端响应。 Async doesn't change the HTTP protocol.
标签: c# asp.net .net asp.net-web-api