asp.net 上传文件大小限制
客户那边老是会遇到上传文件失败的问题。在这里总结一下。
之前的程序员 老是在 web.config 没有定义 maxRequestLength 大小,这样,只要客户上传的文件大于2M 就会上传不成功。
解决方法:在 web.config 文件中,找到 <httpRuntime /> 这一节,位于 system.web 下,没有的话,手动补上,在这一节上加上 maxRequestLength="10240" ,意思就是 上传最大大小是 10 M ,需要其他的大小,修改 其中的数值 就可以。但是如果 这个值过大,比如 50M ,那么最好再加上 executionTimeout="600" ,这是IIS等待时间 (秒),因为上次文件过大,需要的上传的时间也要更多,不然一样会上传失败。
全写如下(请勿直接复制):
<httpRuntime maxRequestLength="10240" executionTimeout="300" />
同时还应在 在 system.webServer 下添加 maxAllowedContentLength
<security> <requestFiltering > <requestLimits maxAllowedContentLength="1024000000" ></requestLimits> </requestFiltering> </security>
Categories:
.net
已禁用评论。