2012-01-24 30 views
6

Ho bisogno di caricare file da 10 GB su IIS in un unico pezzo. Per quanto ne so IIS 7.x/ASP.NET 4.0 non supporta i caricamenti su 2 Gb (alcune persone dicono 4 Gb).Carica file su 2 GB su IIS 8/ASP.NET 4.5?

È stato risolto in IIS 8/ASP.NET 4.5?

+0

Caricare come? Con un 'input type =" file "'? – vcsjones

+0

Utilizzo del verbo PUT. Anche l'uso del caricamento multipart POST con "input type =" file "" è OK, Chrome supporta il caricamento su 2Gb. –

risposta

5

Ecco come faccio a caricare sotto i 4 GB (mi chiedo come rompere anche questo limite): Il pool di applicazioni è .NET 4.0 Modalità classica (Perché non c'è 4.5?). web.config:

<httpRuntime executionTimeout="2400" maxRequestLength="2099999999" /> 
... 
<requestLimits maxAllowedContentLength="4294967290"/> 

Secondo questo articolo http://msdn.microsoft.com/en-us/library/hh195435%28v=vs.110%29.aspx

public override Stream InputStream 
{ 
    get 
    { 
     object workerRequest = ((IServiceProvider)HttpContext.Current).GetService(typeof(HttpWorkerRequest)); 
     bool webDevServer = workerRequest != null && 
          workerRequest.GetType().FullName == "Microsoft.VisualStudio.WebHost.Request"; 

     if (request.GetType().Assembly.GetName().Version.Major >= 4 && !webDevServer) 
     { 
      try // trying to set disableMaxRequestLength true for .NET 4.5 
      { 
       return (Stream)typeof(HttpRequest).GetMethod("GetBufferlessInputStream", BindingFlags.Public | BindingFlags.Instance, null, new[] { typeof(bool) }, null) 
             .Invoke(request, new object[] { true }); 
      } 
      catch (NullReferenceException) 
      { // .NET 4.0 is not patched by adding method overload 
       Log(DateTime.Now + ": Can not invoke .NET 4.5 method"); 
      } 
      return (Stream) typeof (HttpRequest).GetMethod("GetBufferlessInputStream", 
                  BindingFlags.Public | BindingFlags.Instance, 
                  null, new Type[0], null) 
               .Invoke(request, new object[0]); 
     } 
     return request.InputStream; 
    } 
} 

Log dice che il metodo da .NET 4.5 viene chiamato senza eccezioni. Ma questo link http://aspnet.uservoice.com/forums/41199-general-asp-net/suggestions/2642879-maximum-upload-size-in-asp-net-is-2gb-increase-it dice: "Completato, questo limite è stato aumentato in 4.5".

Quindi ho solo una domanda: "COME?"

+2

L'elemento 'requestLimits' sopra menzionato blocca efficacemente IIS a 4 GB. Noi (ASP.NET) abbiamo prototipato e verificato una patch che avrebbe reso il nostro 'maxRequestLength' limitare un intero a 64 bit invece di un intero a 32-bit, ma a causa del cap di IIS hardcoded non abbiamo mai controllato la nostra patch in quanto non sono stato comunque terribilmente utile L'overload GetBufferlessInputStream che hai chiamato è l'unico modo per far sì che ASP.NET ignori il limite 'maxRequestLength'. Stiamo discutendo con il team di IIS per cercare di ottenere il berretto codificato sollevato in una versione futura. – Levi

+0

@Levi Non è necessario sollevare il tappo. Basta rimuoverlo. Questa limitazione di 2 Gb/4 Gb rende IIS/ASP.NET inutilizzabile nei nostri progetti. I nostri clienti devono caricare file da 10 GB tramite browser web (sì, è possibile). –

+0

Mb è possibile con un ambiente selfhosted owin? – smedasn