MVC中上傳檔案大小限制的解決辦法

來源:互聯網
上載者:User

標籤:元素   lte   config檔案   檔案   time   nbsp   程式   pil   server   

在Web.Config檔案中配置限制上傳檔案大小與時間。 

需要在設定檔裡面設定檔案上傳限定的兩個屬性值:maxAllowedContentLength,maxRequestLength 允許上傳檔案的長度,和請求的長度,兩個大小需要設定一致,如果不一致,則以請求長度為準。
maxRequestLength屬性:用於防止伺服器攻擊,例如因使用者向伺服器發送大型檔案而導致的拒絕訪問。預設值為4096(4MB)
ExecutionTimeout屬性:指定在ASP.NET應用程式自動關閉前,允許執行請求的最大秒數。只有當compilation元素中的調試屬性為False時,此逾時屬性才適用。預設值為110s。 

<system.web>
  <httpRuntime maxRequestLength="2147483647" executionTimeout="36000" />
</system.web>

<system.webServer>
  <security>
    <requestFiltering>
      <!--<requestLimits maxAllowedContentLength="1073741824"/>-->
      <requestLimits maxAllowedContentLength="2147483648"/>
    </requestFiltering>
  </security>
</system.webServer>

MVC中上傳檔案大小限制的解決辦法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.