asp .net 大文件傳輸配置

asp .net config配置

須要在配置文件裏面設置文件上傳限定的兩個屬性值:maxAllowedContentLength,maxRequestLength 容許上傳文件的長度,和請求的長度,兩個大小須要設置一致,若是不一致,則以請求長度爲準。(設置的單位都爲byte)
默認請求長度只有4M.web

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

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

服務器配置

權限開放

確保applicationhost.config中對該項修改的權限已經放開
applicationhost.config文件路徑在 C:\Windows\System32\inetsrv\config 下
將requestFiltering從"Deny"改成"Allow"服務器

<sectionGroup name="system.webServer">
  <sectionGroup name="security">
       <section name="requestFiltering" overrideModeDefault="Allow" />
  </sectionGroup>
</sectionGroup>
設置服務器級別的文件上傳大小

在applicationhost.config文件中加上如下字段app

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

能夠經過命令行修改ide

%windir%\system32\inetsrv\appcmd set config -section:requestFiltering -requestLimits.maxAllowedContentLength:2147483647

參考資料

Asp.net MVC 上傳大文件(超過50M)的設置.net

相關文章
相關標籤/搜索