大家好,我在为图像优化内容编写代码时正在 mvc4 中工作,显示错误我需要这样做任何机构请帮助我解决这个问题,我收到了这个错误
这是我的代码:控制器
public ActionResult Uploading(ImageModel model)
{
var uploadFolder = HostingEnvironment.MapPath("~/App_Data");
uploadFolder = Path.Combine(uploadFolder, DateTime.Now.ToString("yyyy/MM/dd/hh/mm/ss/fff"));
Directory.CreateDirectory(uploadFolder);
var streamProvider = new PreserveFilenameMultipartFileStreamProvider(uploadFolder);
Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith(t =>
{
foreach (var uploadedFile in Directory.GetFiles(uploadFolder))
{
var medium = Path.Combine(uploadFolder, "medium-" + Path.GetFileName(uploadedFile));
var thumbnail = Path.Combine(uploadFolder, "thumb-" + Path.GetFileName(uploadedFile));
ImageTools.Resize(uploadedFile, thumbnail, 100, 100);
ImageTools.Resize(uploadedFile, medium, 50, 50);
}
return new HttpResponseMessage()
{
Content = new StringContent("File uploaded.")
};
});
return View("Upload", model);
}
这是我的索引页:
@using (Html.BeginForm("Uploading", "Upload", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" name="ImageUploaded" id="btnUpload" multiple="multiple" accept="image/*" />
<button type="submit" id="Upload">Upload</button>
<br />
//@Html.DisplayForModel(@ViewData["Time"]);
<label>@ViewData["Time"]</label>
}
这里我在内容处收到错误:HTTPRequestBase 不包含内容的定义
Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith(t =>
任何人都可以帮助我解决问题提前谢谢