asp .net config配置
需要在配置文件里面設置文件上傳限定的兩個屬性值:maxAllowedContentLength,maxRequestLength 允許上傳文件的長度,和請求的長度,兩個大小需要設置一致,如果不一致,則以請求長度為准。(設置的單位都為byte)
默認請求長度只有4M.
<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文件中加上以下字段
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
<security>
<system.webServer>
可以通過命令行修改
%windir%\system32\inetsrv\appcmd set config -section:requestFiltering -requestLimits.maxAllowedContentLength:2147483647