C#中使用File 上传文件时,上传文件小于2M可以上传成功,上传文件大于2M就会失败,原因是在Web.config中的上传文件限制,默认情况下为2048KB (2M)
解决方法:如下
<system.web>
<httpRuntime maxRequestLength="2097151" executionTimeout="3600"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
maxRequestLength 这里为最大可上传文件大小 单位为 KB
maxAllowedContentLength 这里为服务器端IIS所允许的最大可上传文件大小 单位为KB