HTTP 错误 404.13 - asp.net core 2.0 [英] HTTP Error 404.13 - asp.net core 2.0
问题描述
HTTP 错误 404.13 - 未找到请求过滤模块是配置为拒绝超过请求内容长度的请求.
HTTP Error 404.13 - Not Found The request filtering module is configured to deny a request that exceeds the request content length.
验证配置/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength在 applicationhost.config 或 web.config 文件中设置.
Verify the configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength setting in the applicationhost.config or web.config file.
我不知道我可以在哪里配置它,在 asp.net core 2 中已经改变使用 appsettings.json.
I've no idea to where can i config that, in asp.net core 2 there has change to use appsettings.json instead.
即使已经尝试这样做,但还是行不通.
Even try to do this already, but it's not work.
services.Configure<FormOptions>(options =>
{
options.MultipartBodyLengthLimit = 300_000_000;
});
推荐答案
如果您使用 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
这篇关于HTTP 错误 404.13 - asp.net core 2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!