首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> .NET 網頁程式設計 >> ASP.NET 基礎 >> 關於ASP.NET

Uploadify 大文件上傳配置全攻略:突破 30MB 限制與 HTTP 404 錯誤排查

     編輯:關於ASP.NET

三步驟突破大小限制

步驟一:Uploadify 客戶端參數調整

$('#file_upload').uploadify({
    'fileSizeLimit': '0',        // 0 = 無限制,或 '100MB'
    'fileTypeDesc': '文件',
    'fileTypeExts': '*.zip; *.rar; *.png',
    // ... 其他配置
});

步驟二:web.config 節點

<system.web>
  <httpRuntime targetFramework="4.5" 
               maxRequestLength="1073741824"      // 單位:KB,此處為 1GB
               executionTimeout="3600" />         // 單位:秒,1小時
</system.web>

注意:maxRequestLength 最大約 2GB (2097151 KB),IIS 7+ 仍受 system.webServer 限制。

步驟三:web.config 節點(關鍵)

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="1073741824" />  // 單位:Byte,1GB
    </requestFiltering>
  </security>
</system.webServer>

IIS 7+ 請求過濾模組默認限制 30MB (30000000 Byte),必須顯式調大 maxAllowedContentLength。

HTTP 404 錯誤常見原因與排查

現象可能原因排查方向
上傳大文件報 404請求體超過 maxAllowedContentLength,IIS 直接拒絕檢查 system.webServer/security/requestFiltering
上傳小文件也 404Uploadify uploader 路徑錯誤 / 路由未匹配瀏覽器 Network 面板查看實際請求 URL
偶發 404應用程序池回收 / Session 丟失檢查 IIS 日誌、應用程序池閒置超時設置

完整 web.config 範例

<configuration>
  <system.web>
    <httpRuntime targetFramework="4.5" maxRequestLength="1073741824" executionTimeout="3600" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

生產環境建議:大文件上傳建議採用分片上傳(如 WebUploader、Plupload、Resumable.js),配合斷點續傳,避免單次大請求導致超時、內存飆升、網絡波動失敗等問題。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved