HTTP Error 404.13 – Not Found The request filtering module is
configured to deny a request that exceeds the request content length.Verify the
configuration/system.webServer/security/requestfiltering/requestLimits@maxAllowedContentLength
setting in the applicationhost.config or web.config file.
我不知道我在哪里可以配置,在asp.net核心2中有改变使用appsettings.json而不是.
甚至尝试这样做,但它不起作用.
services.Configure<FormOptions>(options => { options.MultipartBodyLengthLimit = 300_000_000; });
解决方法
如果您使用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>
如果您不使用IIS,则可以在控制器中使用[RequestSizeLimit(long.MaxValue)]或[disableRequestSizeLimit]属性.
此外,您可以在Program.cs中添加全局设置:
.UseKestrel(o => { o.Limits.MaxRequestBodySize = null; })
有关详细信息,请参阅此https://github.com/aspnet/Announcements/issues/267