HTTP错误404.13 - asp.net核心2.0

Aix*_*asz 9 c# asp.net-mvc .net-core asp.net-core-2.0

HTTP错误404.13 - 未找到请求筛选模块配置为拒绝超过请求内容长度的请求.

验证applicationhost.config或web.config文件中的configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength设置.

我不知道我在哪里可以配置,在asp.net核心2中有改变使用appsettings.json而不是.

甚至尝试这样做,但它不起作用.

services.Configure<FormOptions>(options =>
{
    options.MultipartBodyLengthLimit = 300_000_000;
});
Run Code Online (Sandbox Code Playgroud)

小智 31

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

<?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>
Run Code Online (Sandbox Code Playgroud)

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

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

.UseKestrel(o => { o.Limits.MaxRequestBodySize = null; })
Run Code Online (Sandbox Code Playgroud)

有关详细信息,请参阅https://github.com/aspnet/Announcements/issues/267