尽管已将 MaxRequestLength
和 maxAllowedContentLength
设置为 web.config
部分中的最大可能值,但 ASP.Net Core 不允许我上传大于 134,217,728 字节
的文件。来自网络服务器的确切错误是:
An unhandled exception occurred while processing the request.
InvalidDataException: Multipart body length limit 134217728 exceeded.
有什么办法可以解决这个问题吗? (ASP.Net Core)
最佳答案
我在阅读了 GitHub 上的一些帖子后找到了这个问题的解决方案。结论是它们必须在 Startup
类中设置。例如:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.Configure<FormOptions>(x => {
x.ValueLengthLimit = int.MaxValue;
x.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart
})
}
这样就可以解决问题了。然而,他们还指出有一个 [RequestFormSizeLimit]
属性,但我还无法引用它。
关于asp.net-core - 多部分主体长度超出限制异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40364226/