如何在带有maxAllowedContentLength的IIS上的ASP.NET Core中使用MaxRequestBodySize?

ee

我有一个在IIS上运行的ASP.NET Core Web API。在一个操作中,我设置IHttpMaxRequestBodySizeFeature.MaxRequestBodySize262144000我已经使用IIS配置编辑器来

  • ApplicationHost.config通过设置system.webServer/security/requestFiltering/requestLimits/maxAllowedContentLength修改我的网站4294967295 在此处输入图片说明
  • ApplicationHost.config通过设置system.webServer/serverRuntime/maxRequestEntityAllowed修改我的网站4294967295 在此处输入图片说明
  • Root Web.config通过设置system.web/httpRuntime/maxRequestLength修改我的网站2147483647 在此处输入图片说明

这些是Web.config在IIS配置编辑器中选择时也会看到的值

该站点位于另一个充当反向代理的IIS站点的后面。我在那里做了相同的更改。

我可以上传大于默认的〜30MB限制的文件,但是只要设置IHttpMaxRequestBodySizeFeature.MaxRequestBodySize为较大的值,我始终会收到以下警告

Increasing the MaxRequestBodySize conflicts with the max value for IIS limit maxAllowedContentLength. HTTP requests that have a content-length greater than maxAllowedContentLength will still be rejected by IIS. You can disable the limit by either removing or setting the maxAllowedContentLength value to a higher limit.

I have even looked at the ASP.NET source code to verify that the warning only prints if you're trying to set the limit higher than the IIS settings ([1], [2]).

What am I doing wrong?

If it's relevant, I am publishing to IIS using Azure Pipelines. My repo does not contain a web.config, but for good measure I tried with the following web.config without luck:

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="4294967295" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>
cmeeren

事实证明,将限制设置为Int32.MaxValue以上的值时,ASP.NET Core中存在多个错误。此外,该限制必须在两个地方设置。请参阅此问题和链接的问题。综上所述:

  • web.config设置system.webServer.security.requestFiltering.maxAllowedContentLengthInt32.MaxValue
  • 在应用启动时,设置IISServerOptions.MaxRequestBodySizeInt32.MaxValue

这样就消除了警告(当然,将请求限制为〜2GB)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在带有 ASP.NET Core 的控制器中使用泛型方法

来自分类Dev

如何在带有Polymer的Visual Studio ASP.NET Core应用程序中使用照明元素

来自分类Dev

如何在.net Core中使用RSA

来自分类Dev

如何在IIS上使用ASP.NET Core 3.1 API部署Angular SPA?

来自分类Dev

如何在ASP.NET Core应用中使用HttpClient

来自分类Dev

如何在ASP.NET Core中使用jquery

来自分类Dev

是否可以在带有.NET Framework的.NET Core中使用

来自分类Dev

如何在带有Servicestack的.NET Core中使用Windows身份验证登录

来自分类Dev

如何在带有 Ajax Post 的 .net core mvc 中使用模型绑定器?

来自分类Dev

在ASP.NET Core中使用MimeMapping

来自分类Dev

在ASP.net Core中使用BeginCollectionItem

来自分类Dev

在ASP.NET Core中使用DirectoryServices

来自分类Dev

如何在ASP.NET MVC中使用带有DescriptionAttribute的枚举

来自分类Dev

如何修复IIS上的ASP.Net Core 404错误?

来自分类Dev

如何在mongodb的.net Core中使用hangfire?

来自分类Dev

如何在Google Cloud中使用.Net Core 3.0映像?

来自分类Dev

如何在Dot Net Core 3.1中使用FromSqlInterpolated / Database.ExecuteSqlInterpolated执行带有输出参数的存储过程?

来自分类Dev

如何在IIS下运行ASP.NET Core站点

来自分类Dev

如何在ASP.NET Core中获取IIS版本

来自分类Dev

如何在IIS下运行ASP.NET Core站点

来自分类Dev

如何在带有身份的ASP.NET Core项目中禁用HTTPS?

来自分类Dev

在 Azure 站点上的 ASP.Net Core Razor 中使用具有配置的 SendGrid 邮件

来自分类Dev

默认情况下,如何在ASP.NET Core中使用承载令牌保护所有控制器?

来自分类Dev

如何在没有 javascript 的 asp.net-core 中使用单选按钮过滤我的部分视图?

来自分类Dev

如何在ASP.NET CORE 3.0中配置路由以使用带有[FromQuery]参数的重载[HttpGet]方法?

来自分类Dev

如何在ASP.NET中使用<%%>?

来自分类Dev

如何在asp.net中使用<%%>?

来自分类Dev

如何在Asp.net Core rc1中的静态方法中使用DI

来自分类Dev

如何在C#UWP应用程序中使用ASP.NET Core WebAPI?

Related 相关文章

  1. 1

    如何在带有 ASP.NET Core 的控制器中使用泛型方法

  2. 2

    如何在带有Polymer的Visual Studio ASP.NET Core应用程序中使用照明元素

  3. 3

    如何在.net Core中使用RSA

  4. 4

    如何在IIS上使用ASP.NET Core 3.1 API部署Angular SPA?

  5. 5

    如何在ASP.NET Core应用中使用HttpClient

  6. 6

    如何在ASP.NET Core中使用jquery

  7. 7

    是否可以在带有.NET Framework的.NET Core中使用

  8. 8

    如何在带有Servicestack的.NET Core中使用Windows身份验证登录

  9. 9

    如何在带有 Ajax Post 的 .net core mvc 中使用模型绑定器?

  10. 10

    在ASP.NET Core中使用MimeMapping

  11. 11

    在ASP.net Core中使用BeginCollectionItem

  12. 12

    在ASP.NET Core中使用DirectoryServices

  13. 13

    如何在ASP.NET MVC中使用带有DescriptionAttribute的枚举

  14. 14

    如何修复IIS上的ASP.Net Core 404错误?

  15. 15

    如何在mongodb的.net Core中使用hangfire?

  16. 16

    如何在Google Cloud中使用.Net Core 3.0映像?

  17. 17

    如何在Dot Net Core 3.1中使用FromSqlInterpolated / Database.ExecuteSqlInterpolated执行带有输出参数的存储过程?

  18. 18

    如何在IIS下运行ASP.NET Core站点

  19. 19

    如何在ASP.NET Core中获取IIS版本

  20. 20

    如何在IIS下运行ASP.NET Core站点

  21. 21

    如何在带有身份的ASP.NET Core项目中禁用HTTPS?

  22. 22

    在 Azure 站点上的 ASP.Net Core Razor 中使用具有配置的 SendGrid 邮件

  23. 23

    默认情况下,如何在ASP.NET Core中使用承载令牌保护所有控制器?

  24. 24

    如何在没有 javascript 的 asp.net-core 中使用单选按钮过滤我的部分视图?

  25. 25

    如何在ASP.NET CORE 3.0中配置路由以使用带有[FromQuery]参数的重载[HttpGet]方法?

  26. 26

    如何在ASP.NET中使用<%%>?

  27. 27

    如何在asp.net中使用<%%>?

  28. 28

    如何在Asp.net Core rc1中的静态方法中使用DI

  29. 29

    如何在C#UWP应用程序中使用ASP.NET Core WebAPI?

热门标签

归档