找不到文件或目录

时间:2018-12-16 13:31:30

标签: asp.net-mvc

我可以使用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");
    }

1 个答案:

答案 0 :(得分:0)

如果您使用IIS进行托管,请配置web.config

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="1073741824" /> <!- 1 Gb ->
    </requestFiltering>
  </security>
</system.webServer>