首先,最容易找到的是web.config下面配置:html
<!--maxRequestLength=50MB--> <httpRuntime targetFramework="4.5.2" maxRequestLength="51200"/>
这么设置会将请求的尺寸从默认4MB(4096KB)提高到50MB(51200KB)。web
可是,若是只是这么设置的话,你会发现你的最大上传尺寸会中止在28.6MB,更大的文件上传,将返回404.13,表示内容长度过大。服务器
缘由在于IIS的默认设置,限定了maxAllowedContentLength的值。app
<element name="requestLimits"><attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" />
该值在IIS_Schema.xml中设置。(将影响整个计算机)ide
IISExpress:IISExpress运行路径下,C:\Program Files (x86)\IIS Express\config\schema\IIS_schema.xml
IIS七、8:C:\Windows\System32\inetsrv\config\schema\IIS_schema.xmlui
若是修改了这个值没有生效,两种可能,一种是当前运行的IISExpress/IIS没有关闭/重启。一种是web.config中有额外的配置(以下文所述)。spa
然而为了不老是去修改全局的值,影响到同一台服务器上的其余web站点,咱们还能够在web.config中进行配置。.net
<system.webServer> <!-- IISExpress:C:\Users\UserName\Documents\IISExpress\config\applicationHost.config IIS七、8:C:\Windows\System32\inetsrv\config\applicationHost.config <section name="requestFiltering" overrideModeDefault="Allow" /> overrideModeDefault值设置成Allow的时候,本配置节才会生效。 也能够在IIS_Schema.xml中设置。(将影响整个计算机) IISExpress:IISExpress运行路径下,C:\Program Files (x86)\IIS Express\config\schema\IIS_schema.xml IIS七、8:C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml 修改defaultValue="30000000"(28.6MB)为须要的值。 <element name="requestLimits"><attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" /> --> <security> <requestFiltering> <!--maxAllowedContentLength=100MB--> <requestLimits maxAllowedContentLength="104857600"></requestLimits> </requestFiltering> </security>
为了使该内容生效,须要配置“容许继承”,在applicationHost.config中搜索<section name="requestFiltering" overrideModeDefault="Allow" />中的关键字,确保这个值为Allow便可。code
IISExpress:C:\Users\UserName\Documents\IISExpress\config\applicationHost.config
IIS七、8:C:\Windows\System32\inetsrv\config\applicationHost.configserver
参考资料:
http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits
http://www.cnblogs.com/henryhappier/archive/2010/09/20/1832098.html
https://msdn.microsoft.com/en-us/library/ms689462(v=vs.90).aspx