NET程序部署到IIS环境上,因为IIS默认请求长度4M,当请求长度大于这个值的时候如下图所示报错

解决办法
1、修改maxRequestLength参数,这个参数在web.config配置中的<system.web></system.web>配置段中的maxRequestLength参数,默认是4M,我们可以修改成如下,如果没有则添加 <httpRuntime maxRequestLength="20480" />
<system.web> <!--最大请求长度,单位为kb--> <httpRuntime maxRequestLength="20480" /> </system.web>
2、修改修改maxAllowedContentLength参数,这个参数在web.config配置中的<system.webServer></system.webServer>配置段中的maxAllowedContentLength,表示附件大小上限,单位是字节,默认约30M
<system.webServer> <!--允许上传文件长度,单位字节--> <security> <requestFiltering> <requestLimits maxAllowedContentLength="20971520"/> </requestFiltering> </security> </system.webServer>
PS:maxRequestLength与maxAllowedContentLength的区别,以上两个配置段如果没有则添加,如果有则修改它的值

