azure-web-app-service - 将大文件上传到 Azure 中的 dotnetcore 应用程序失败 (404)
问题描述
我无法上传大文件,我不确定它是否仍然是大小限制或超时。
在控制器端点上,我尝试了我找到的所有属性(一次)
[HttpPost("[action]")]
[DisableRequestSizeLimit]
[RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue, BufferBodyLengthLimit = long.MaxValue)]
[RequestSizeLimit(int.MaxValue)]
public async Task UploadForm()
在“ConfigureServices”期间,我还设置了这个:
services.Configure<FormOptions>(options =>
{
options.MemoryBufferThreshold = int.MaxValue;
options.ValueLengthLimit = int.MaxValue;
options.ValueCountLimit = int.MaxValue;
options.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart
});
但是上传文件的一部分后我仍然收到 404 错误(30 MB 已经太多了)。
然后我什至尝试使用以下代码设置红隼,但应用程序甚至无法启动(502)
.UseKestrel((KestrelServerOptions o) =>
{
o.Limits.KeepAliveTimeout = TimeSpan.FromMinutes(120);
o.Limits.RequestHeadersTimeout = TimeSpan.FromMinutes(120);
o.Limits.MaxRequestBodySize = null;
})
解决方案
看看这个官方文档。
解决方案:
更改 的值maxAllowedContentLength
。
在 Web.config 中添加这些代码(在 Kudu 上的 site/wwwroot 下):
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="<valueInBytes>"/>
</requestFiltering>
</security>
</system.webServer>
</configuration>
这应该无需重新启动即可工作。
推荐阅读
- excel - 不同命名表中的间接索引和匹配问题公式
- django - graphene-django 为 DjangoFilterConnectionField 添加附加参数并将其传递给 get_queryset
- c# - 如何使用 linq lamba 表达式通过内部连接进行分组
- javascript - 在反应中存储来自多个选择的值
- haskell - 有没有办法在模式匹配期间绑定存在数据类型的抑制类型变量?
- python - Pandas:具有另一列唯一值索引的新列
- powershell - 启动 docker 容器时防止 Gitlab 添加 -NoProfile 到 PowerShell
- r - 使用for循环将多个图像(3D数组)存储到R中的4D数组中
- jenkins - 如何从Jenkins的工作区获取文件路径
- gitlab - GitLab CI 更改变量