I am trying to upload a 5.25 MB mp4 video file in an ASP.NET MVC 5 application.
I tried adding this to the Web.config file, which in most cases was the accepted answer to this problem.
<system.web> <httpRuntime maxRequestLength="1048576" /> </system.web>
I also tried setting a timeout also in Web.config
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
However, when I go to download the file, I get a System.Web.HttpException (0x80004005): Maximum request length exceeded.
Perhaps there is something that needs to be installed in the controller or in the view?
Controller:
[HttpPost] public ActionResult Index(HttpPostedFileBase file) { if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); if (fileName != null) { var path = Path.Combine(Server.MapPath("~/Content/Videos"), fileName); file.SaveAs(path); } } return RedirectToAction("Index"); }
View:
@using (Html.BeginForm("Edit", "Posts", FormMethod.Post, new { enctype = "multipart/form-data" })) { <input type="file" name="file" /> <input type="submit" value="OK" /> }
How do you upload video files to ASP.NET MVC 5?
asp.net-mvc
Jonathan kittell
source share