2014-10-18 12 views
8

Sto tentando di caricare un file video mp4 di 5,25 MB in un'applicazione ASP.NET MVC 5.System.Web.HttpException (0x80004005): lunghezza massima richiesta superata

Ho provato ad aggiungere questo al file Web.config che è stato la risposta accettata nella maggior parte dei casi a questo problema.

<system.web> 
    <!-- This will handle requests up to 1024MB (1GB) --> 
    <httpRuntime maxRequestLength="1048576" /> 
</system.web> 

Ho anche provato a installare il timeout e nel web.config

<httpRuntime maxRequestLength="1048576" executionTimeout="3600" /> 

Tuttavia, quando vado a caricare il file che sto ottenendo System.Web.HttpException (0x80004005): Maximum request length exceeded.

Forse c'è qualcosa che deve essere impostato nel controller o nella vista?

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

Vista:

@using (Html.BeginForm("Edit", "Posts", FormMethod.Post, new { enctype = "multipart/form-data" })) 
{ 
    <input type="file" name="file" /> 
    <input type="submit" value="OK" /> 
} 

Come si fa a caricare i file video in ASP.NET MVC 5?

+2

Questo potrebbe aiutare. http://stackoverflow.com/questions/3853767/maximum-request-length-exceeded –

+0

Questa domanda sembra essere off-topic perché è un duplicato esatto di http://www.google.com/#q=Maximum% 20request% 20length% 20exceeded –

+3

@ ta.speot.is "Posso trovarlo su google" in nessun modo lo rende fuori tema. Essere un duplicato di un'altra domanda SO rende comunque richiudibile un duplicato. –

risposta

13

Prova aggiungere questo nel web.config (in byte!):

<system.webServer> 
    <security> 
     <requestFiltering> 
     <requestLimits maxAllowedContentLength="1073741824" /> 
     </requestFiltering> 
    </security> 
</system.webServer> 
Problemi correlati