Web.config 忽略 maxRequestLength,只有 maxAllowedContentLength 有效

Web.config maxRequestLength ignored, only maxAllowedContentLength works

我已经搜索了一段时间,但似乎找不到任何可以处理我所面临的具体情况的内容。

我像这样将 maxRequestLength 设置为 5MB...

<httpRuntime maxRequestLength="5120"/>

然后我将 maxAllowedContentLength 设置为 20MB...

<requestLimits maxAllowedContentLength="20971520"/>

由于某种原因,尽管忽略了下限。我的应用程序允许上传最大 20MB 的文件。

它认为任何超过 maxRequestLength 的东西都应该触发 .Net 异常。

该应用程序是经典的 ASP,具有管理上传的自定义 Interop COM 对象。

如果我直接使用 .Net 上传,会遵守限制并抛出异常。

有谁知道为什么 ASP and/or COM 会忽略 maxRequestLength?

这发生在 IIS 8 和 IIS 10 中。

我有下面的一套,如果它有所作为...

<modules runAllManagedModulesForAllRequests="true"/>

Does anyone know why maxRequestLength is ignored for ASP and/or COM?

与所有其他 system.web 设置一样,它是一个 ASP.NET 设置。你已经体验过了。所以对于非 ASP.NET 请求被忽略是正常的。

来自httpRuntime Element (ASP.NET Settings Schema)

Configures ASP.NET HTTP run-time settings that determine how to process a request for an ASP.NET application.