Asp.net

ASP .Net 文件上傳最大請求長度超出錯誤

  • February 3, 2016

我在頁面上有一個簡單的 ASP .Net 文件上傳控制項。我有以下 web.config 設置

<system.webServer>
     <security>
     <requestFiltering>
       <requestLimits maxAllowedContentLength="524288000" />
     </requestFiltering>
   </security>
</system.webServer>

   <system.web>
     <httpRuntime maxRequestLength="524288" executionTimeout="120000" />
   </system.web>

我在開發盒上使用 IIS 7.5,在 Web 伺服器上使用 IIS 7。

如果我上傳大小為 7MB 的文件,它工作正常。

但是當我上傳 10MB 的文件時,它會拋出以下異常

我在頁面上有一個簡單的 ASP .Net 文件上傳控制項。我有以下web.config設置

Exception Details: System.Web.HttpException: Maximum request length exceeded.

Stack Trace:     

[HttpException (0x80004005): Maximum request length exceeded.]
  System.Web.HttpRequest.GetEntireRawContent() +8772610
  System.Web.HttpRequest.GetMultipartContent() +62
  System.Web.HttpRequest.FillInFormCollection() +168
  System.Web.HttpRequest.get_Form() +68
  System.Web.TraceContext.InitRequest() +910
  System.Web.TraceContext.VerifyStart() +143
  System.Web.HttpApplication.AssignContext(HttpContext context) +118
  System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +464

任何幫助將不勝感激。我知道這個問題已經被問過很多次了,但是這些解決方案都不適合我。

我們正在使用 Sitecore 內容管理系統。

我終於解決了。當我們使用 Sitecore 時,我們將頁面作為特定路徑的內容樹上的一個項目。現在我們還有一些駐留在文件系統上的舊頁面。這些駐留在文件系統上的頁面有自己的本地 web.config 文件,該文件具有有限的最大請求長度。此設置在上傳大文件時會產生問題。

謝謝大家的幫助。

您的 maxRequestLength 設置為過大的 512 MB。嘗試將其設置為 12MB。

如果是 IIS 阻塞,請嘗試將其設置為非應用程序級別;而是在文件夾中創建一個 Web.Config。

更多資訊在這裡:

http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx

引用自:https://stackoverflow.com/questions/12680347