繁体   English   中英

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

[英]How to set the maxAllowedContentLength to 500MB while running on IIS7?

我将 maxAllowedContentLength 更改为

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

在我的 web.config 中,但在 IIS7 上运行时出现此错误:

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

http://i.stack.imgur.com/u1ZFe.jpg

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

如何配置我的网站以允许上传 500MB 大小的文件,而在 IIS7 上没有这个问题?

.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>

根据MSDN maxAllowedContentLength类型为uint ,其最大值为 4,294,967,295 字节 = 3,99 gb

所以它应该可以正常工作。

另请参阅请求限制文章 当根本没有配置适当的部分时,IIS 是否返回这些错误之一?

另请参阅: 超出最大请求长度

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

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

maxAllowedContentLength最大值为: UInt32.MaxValue 🡒 4294967295 bytes~4GB

maxRequestLength最大值为: Int32.MaxValue 🡒 2147483647 bytes~2GB

网页配置

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <!-- ~ 2GB -->
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <!-- ~ 4GB -->
        <requestLimits maxAllowedContentLength="4294967295" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM