多部分车身长度限制超出例外

多部分车身长度限制超出例外

本文介绍了多部分车身长度限制超出例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尽管已将MaxRequestLengthmaxAllowedContentLength设置为web.config部分中的最大可能值,但是ASP.Net Core不允许我上传大于134,217,728 Bytes的文件.来自网络服务器的确切错误是:

Although having set the MaxRequestLength and maxAllowedContentLength to the maximum possible values in the web.config section, ASP.Net Core does not allow me to upload files larger than 134,217,728 Bytes. The exact error coming from the web server is:

InvalidDataException:超出了多部分主体的长度限制134217728.

InvalidDataException: Multipart body length limit 134217728 exceeded.

有什么办法可以解决这个问题? ( ASP.Net Core )

Is there any way to work this around? (ASP.Net Core)

推荐答案

在阅读GitHub上的一些帖子后,我找到了解决此问题的方法.结论是必须在Startup类中设置它们.例如:

I found the solution for this problem after reading some posts in GitHub. Conclusion is that they have to be set in the Startup class. For example:

public void ConfigureServices(IServiceCollection services)
{
        services.AddMvc();
        services.Configure<FormOptions>(x => {
            x.ValueLengthLimit = int.MaxValue;
            x.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart
        })
 }

这将解决问题.但是,他们还指出有一个[RequestFormSizeLimit]属性,但是我还不能引用它.

This will solve the problem. However they also indicated that there is a [RequestFormSizeLimit] attribute, but I have been unable to reference it yet.

这篇关于多部分车身长度限制超出例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 22:33