maxAllowedContentLength在IIS7中对于IHttpHandler无效。

4

我有一个处理文件上传的ASP.NET IHttpHandler模块。我在配置文件中设置了文件大小限制为50MB。

  <system.webServer>
   <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="52428800" />
      </requestFiltering>
    </security> 
  </system.webServer>

但是上传13MB文件时仍然出现错误。

System.Web.HttpException (0x80004005): Maximum request length exceeded.

如何增加默认允许的文件大小?

3个回答

2

总之,要将IIS7中的文件上传大小提高到50 MiB,请在Web.config文件的正确部分添加以下行:

  <system.webServer>
   <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="52428800" />
      </requestFiltering>
    </security> 
  </system.webServer>

并且。
  <system.web>
    <httpRuntime maxRequestLength="51200" />
  </system.web>

50 MiB相当于5242880字节

50 MiB相当于51200 Kib


1

在 Web 应用程序的 web.config 中,使用以下内容:

<httpRuntime maxRequestLength="52428800" />

3
这实际上是错误的-https://dev59.com/nnE85IYBdhLWcg3wejZO#3787284/-这里需要使用千字节。 - sharptooth
正确的maxRequestLength以KB为单位,请参见此处:http://msdn.microsoft.com/en-gb/library/e1f13641%28v=vs.85%29.aspx - AJ Dhaliwal

0

对于经典 ASP 用户,除了 web.config 设置之外,还要检查以下设置:

IIS > 点击网站 > ASP > 限制属性 > 最大请求实体正文限制


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接