Asynchronous can';未找到t compile-Request.Content.IsMimeMultipartContent()
我有以下代码:Asynchronous can';未找到t compile-Request.Content.IsMimeMultipartContent(),asynchronous,system.net,Asynchronous,System.net,我有以下代码: public class UploadController : ApiController { DBRepository _repository = new DBRepository(); public Task<IEnumerable<FileDesc>> Post() { string folderName = "UploadedFiles"; string PATH = HttpCon
public class UploadController : ApiController
{
DBRepository _repository = new DBRepository();
public Task<IEnumerable<FileDesc>> Post()
{
string folderName = "UploadedFiles";
string PATH = HttpContext.Current.Server.MapPath("~/" + folderName);
PATH = @"c:\www\qqq";
string rootUrl = Request.RequestUri.AbsoluteUri.Replace(Request.RequestUri.AbsolutePath, String.Empty);
if (Request.Content.IsMimeMultipartContent())
{
var streamProvider = new CustomMultipartFormDataStreamProvider(PATH);
var task = Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith<IEnumerable<FileDesc>>(t =>
{
if (t.IsFaulted || t.IsCanceled)
{
throw new HttpResponseException(HttpStatusCode.InternalServerError);
}
return fileInfo;
});
return task;
}
else
{
throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotAcceptable, "This request is not properly formatted"));
}
}
}
在第页上仔细地说,这个ext.方法在System.Net.Http.Formatting(在System.Net.Http.Formatting.dll中)中
我试着在4.0和4.5下编译这个项目-没有效果
另外,我有一个使用相同代码的解决方案,它可以完美地工作。我能做什么?添加以下参考: “使用System.Net.Http;”
{}的链接到的MSDN页面在
System.Net.Http
命名空间中显示它。您是否缺少使用声明?谢谢!真是愚蠢的错误,我检查了两次,但无论如何都失败了…我有同样的问题,但我添加了这个参考,并在顶部有这一行。但是关于“多部分”的一切都找不到。我还遗漏了什么吗?请尝试在package Manager控制台中输入“update package”命令
using System.Net.Http.Formatting;