2012-01-24 38 views
6

我需要將10Gb文件上傳到IIS中。據我所知IIS 7.x/ASP.NET 4.0不支持2Gb以上的上傳(有人說4Gb)。通過2Gb上傳文件到IIS 8/ASP.NET 4.5?

它在IIS 8/ASP.NET 4.5中修復了嗎?

+0

上傳怎麼樣?用'input type =「file」'? – vcsjones

+0

使用PUT動詞。使用POST分段上傳和「input type =」file「'也可以,Chrome支持通過2Gb上傳。 –

回答

5

下面是我如何上傳低於4GB(我不知道如何突破這個限制): 應用程序池是.NET 4.0 Classic模式(爲什麼沒有4.5?)。 web.config中:

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

根據這篇文章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; 
    } 
} 

日誌說,從.NET 4.5方法被稱爲無異常。 但這個鏈接http://aspnet.uservoice.com/forums/41199-general-asp-net/suggestions/2642879-maximum-upload-size-in-asp-net-is-2gb-increase-it說:「已完成,這個限制正在增加4.5。」

所以我只有一個問題:「怎麼了?」

+2

上面提到的'requestLimits'元素有效地限制了4GB的IIS。我們(ASP.NET)原型化並驗證了一個補丁,它將使我們的'maxRequestLength'限制64位整數而不是32位整數,但由於硬編碼的IIS限制,我們從未檢查過我們的補丁,因爲它不會反正非常有用。您調用的GetBufferlessInputStream重載是讓ASP.NET忽略「maxRequestLength」限制的唯一方法。我們正在與IIS團隊進行討論,試圖在未來版本中取消硬編碼上限。 – Levi

+0

@Levi無需提起帽子。只要刪除它。此2Gb/4Gb限制使IIS/ASP.NET在我們的項目中無法使用。我們的客戶需要通過網絡瀏覽器上傳10Gb文件(是的,這是可能的)。 –

+0

Mb它可能與owin selfhosted環境? – smedasn