超出最大的要求長度

  • 112
  • 0
  • 2020-12-26

超出最大的要求長度

最近的案子使用者在使用上傳檔案的物件時,上傳過大的檔案會跑出此錯誤

但是我明明有檢檔案的大小在做上傳

結果實際測試時,檢查都沒檢查,直接丟出例外錯誤....心想真奇怪,於是就google一下拉

原來

除了在WebConfig,System.web裡設定,maxrequestlength(單位為byte)以外

<httpRuntime targetFramework="4.5" maxRequestLength="1073741824" executionTimeout="600" />

還要再System.webserver設定,maxallowedcontentlength(單位為byte)

 <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
 </security>