locked
404 - File or directory not found RRS feed

  • Question

  • User410348098 posted

    Hi,

    I can successfully upload a file using MVC but when the file gets great a little bit I encountered the following error:

    This is my codes:

    [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");
            }
    

    Sunday, December 16, 2018 12:52 PM

Answers

  • User1724605321 posted

    Hi Eminent,

    Please try to config the maxRequestLength within your web.config to handle files and uploads that are large :

    <configuration>
        <system.web>
            <!-- This will handle requests up to 50MB  -->
            <httpRuntime maxRequestLength="51200" timeout="3600" />
        </system.web>
    </configuration>
    
    <!-- IIS Specific Targeting (noted by the system.webServer section) -->
    <system.webServer>
       <security>
          <requestFiltering>
             <!-- This will handle requests up to 50MB -->
             <requestLimits maxAllowedContentLength="52428800" />
          </requestFiltering>
       </security>
     </system.webServer>

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 17, 2018 2:22 AM