且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HTTP 错误 404.13 - asp.net core 2.0

更新时间:2023-02-16 09:52:16

如果您使用 IIS,则需要在您的 asp.net core 2.0 应用程序中添加 web.config.

If you use IIS, you need add web.config in your asp.net core 2.0 app.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <security>
      <requestFiltering>
        <!-- This will handle requests up to 700MB (CD700) -->
        <requestLimits maxAllowedContentLength="737280000" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

如果您不使用 IIS,您可以在控制器中使用 [RequestSizeLimit(long.MaxValue)][DisableRequestSizeLimit] 属性.

If you are not using IIS you can use [RequestSizeLimit(long.MaxValue)] or [DisableRequestSizeLimit] attribute in your controller.

此外,您可以在 Program.cs 中添加全局设置:

Also, you can add a global setting in Program.cs:

.UseKestrel(o => { o.Limits.MaxRequestBodySize = null; })

有关更多信息,请参阅此 https://github.com/aspnet/Announcements/issues/267

For more info see this https://github.com/aspnet/Announcements/issues/267