我可以使用MVC成功上传文件,但是当文件变得很小一点时,我遇到了以下错误:
HTTP Error 404- File or Directory not found
这是我的代码:
[HttpPost]
public ActionResult SubmitProductCatTizer(MZPDB.ProductCatTizer model, long proCatId, HttpPostedFileBase file)
{
if (ModelState.IsValid)
{
if (file == null)
return RedirectToAction("AddProductCatTizer");
var guid = Guid.NewGuid().ToString("N");
var fullPath = Server.MapPath("~/Uploaded/" + guid + ".mp4");
file.SaveAs(fullPath);
Dbcontex.ProductCatTizers.Add(new MZPDB.ProductCatTizer()
{
Title = model.Title,
Description = model.Description,
ProductCatId = proCatId,
VideoFile = guid,
Status = true
});
Dbcontex.SaveChanges();
return RedirectToAction("ListProductCatTizer", "ListAdmin", new { area = "AdminPanel" });
}
return View("AddProductCatTizer");
}
答案 0 :(得分:0)
如果您使用IIS进行托管,请配置web.config
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" /> <!- 1 Gb ->
</requestFiltering>
</security>
</system.webServer>