上传超过 100MB 的文件时出现 404 aspnet core 3.1

404 when uploading a file over 100MB aspnet core 3.1

我正在使用 mvc 开发一个 asp.net 核心 3.1 应用程序,我应该在其中上传最大 200mb 的文件。 上传最多 100mb 的作品,但超过任何内容都会给我一个 404。

直接说代码不是我写的,大部分配置都是用Kapitan驱动的,对我来说是全新的

这是一个模拟表格:

        @using (@Html.BeginForm("Create", "Model", FormMethod.Post, htmlAttributes: new { @class = "form", enctype = "multipart/form-data" }))
        { 
            <div class="form-group">
                @Html.Label("x File")
                @Html.TextBoxFor(x => x.Model.x, htmlAttributes: new
                {
                    type = "file",
                    accept = ".x",
                    required = "true"
                })
            </div>
        }

控制器:

    [HttpPost]
    [RequestFormLimits(MultipartBodyLengthLimit = 568435456)]
    public async Task<IActionResult> Create(X x)
    {
    }

我尝试过的事情: 添加 web.config

<?xml version="1.0" encoding="utf-8"?>

        <configuration>
            <system.web>
                <httpRuntime maxRequestLength="307200" />
            </system.web>
            <system.webServer>
                <security>
                    <requestFiltering>
                        <requestLimits maxAllowedContentLength="524288000" />
                    </requestFiltering>
                </security>
            </system.webServer>
        </configuration>

启动:

        services.Configure<FormOptions>(options =>
        {
            options.MultipartBodyLengthLimit = 568435456;
        });

更改代理主体大小的 yml 文件的配置删除了我以前从 nginx 获取的 413 而不是 404。

更新

在隐身模式下,响应变为:

502 错误网关 nginx/1.17.10

可能是什么原因?我尝试了所有可以在网上找到的东西。

提前谢谢你。

对于可能遇到此问题的人来说,问题是由 OOM 引起的,因为代码中的某处存在管理不善的流。 404 响应似乎是由于 Pod 在响应完成之前失败(因为达到了内存限制)而导致的。 非常感谢@Abdusco 在调试问题时提供的宝贵帮助。