Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multipart body length limit exceeded exception

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:

An unhandled exception occurred while processing the request.

InvalidDataException: Multipart body length limit 134217728 exceeded.

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

like image 215
Transcendent Avatar asked Nov 01 '16 16:11

Transcendent


1 Answers

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         })  } 

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

like image 70
Transcendent Avatar answered Sep 29 '22 05:09

Transcendent