问题描述:js上传大文件(超过30M),后台接收不到
环境描述:vs2012 .net4.5 dojo
使用dojo的Uploader控件上传文件,当文件大小超过30M时,后台不能正常接收。
这是由vs所使用的IIS Express默认设置造成的。
解决方案:
在参考过http://www.cnblogs.com/henryhappier/archive/2010/09/20/1832098.html后,简单步骤罗列如下:
第一步,在.net的Web工程下,修改Web.config文件设置,添加
<httpRuntime executionTimeout="1200" maxRequestLength="512000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="512000"/>
此处的maxRequestLength单位为kb。
第二部,修改IIS Express配置文件
找到IIS Express的配置文件,一般路径为C:\Users\Sun\Documents\IISExpress\config\applicationhost.config,
添加
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000"/>
</requestFiltering>
</security>
</system.webServer>
注意,<system.webServer> <security> <requestFiltering>可能已经存在,结合实际情况添加
此处我只添加了这一句话。这里的maxAllowedContentLength值单位为byte。
在设置大小时,第一步与第二部中设置的值最好在换算后为同样大小。
问题基本解决。