Asp.net 在IIS7上运行时,如何将maxAllowedContentLength设置为500MB?

Asp.net 在IIS7上运行时,如何将maxAllowedContentLength设置为500MB?,asp.net,iis-7,file-upload,.net-4.0,Asp.net,Iis 7,File Upload,.net 4.0,我将maxAllowedContentLength更改为 <security> <requestFiltering> <requestLimits maxAllowedContentLength="5024000000" /> </requestFiltering> </security> 在我的web.config中,但在IIS7上运行时,我得到以下错误: “maxAllowedContentLe

我将maxAllowedContentLength更改为

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="5024000000" />
    </requestFiltering>
</security>

在我的web.config中,但在IIS7上运行时,我得到以下错误:

“maxAllowedContentLength”属性无效。不是有效的无符号整数

但是当我在VS服务器上运行时,它正常运行,没有任何错误

如何配置我的网站以允许上传500MB大小的文件,而不在IIS7上出现此问题?

根据
maxAllowedContentLength
的类型
uint
,它是4294967295字节=3,99 gb

所以它应该可以正常工作

另见。当完全没有配置相应的节时,IIS是否返回这些错误之一


另请参见:

可以同时从两个属性配置.Net中的请求限制:

弗斯特
  • Web.Config/system.Web/httpRuntime/maxRequestLength
  • 计量单位:千字节
  • 默认值4096 KB(4 MB)
  • 最大值2147483647 KB(2 TB)
第二
  • Web.Config/system.webServer/security/requestFiltering/requestLimits/maxAllowedContentLength
    (字节)
  • 计量单位:字节
  • 默认值30000000字节(28.6 MB)
  • 最大值4294967295字节(4 GB)
参考资料:

例如:

<location path="upl">
   <system.web>
     <!--The default size is 4096 kilobytes (4 MB). MaxValue is 2147483647 KB (2 TB)-->
     <!-- 100 MB in kilobytes -->
     <httpRuntime maxRequestLength="102400" />
   </system.web>
   <system.webServer>
     <security>
       <requestFiltering>          
         <!--The default size is 30000000 bytes (28.6 MB). MaxValue is 4294967295 bytes (4 GB)-->
         <!-- 100 MB in bytes -->
         <requestLimits maxAllowedContentLength="104857600" />
       </requestFiltering>
     </security>
   </system.webServer>
 </location>

IIS v10(但这对于IIS 7.x也应该是相同的)

为寻找各自最大值的人快速添加

maxAllowedContentLength
的最大值为:
UInt32.MaxValue

所以我得到的502400000这个值是按gb计算的?!500MB=524288000,现在小于4294967295非常有用,但是我认为maxAllowedContentLength的最大值大约是4GB,而不是4GB。文章说“指定请求中内容的最大长度,以字节为单位。”。意味着两个配置键都使用字节使最大请求大小相同,4GB.502400000(让我添加千个分隔符)5.024.000.000大于最大无符号整数4.294.967.295,您在ur配置中寻找502.400.000作为值(没有千个分隔符)更改“httpRuntime maxRequestLength”不是一个好的做法(DoS),您需要更改的是“requestLimits maxAllowedContentLength”