加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – HTTP错误404.13 – asp.net core 2.0

发布时间:2020-12-15 19:53:59 所属栏目:百科 来源:网络整理
导读: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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读