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)
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 = long.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.