I am trying to 'upload' a video file in to my application and pass it to the database. I am able to handle pictures quite nicely however as soon as I try larger / video files I am getting a Status: 400 error code when a Submit is made.
I put a break point on the OnPostAsync
method in code behind but it doesn't get hit.
I just have a standard Input --> Type: File:
and from seeing a few mentions online I have manually added a web.config
file to the project and added the following:
However I still get the 400 error if I attempt to upload a large file. I notice in the actual call it should allow the mime type:
As per other advice I have also tried adding the following to the
but get the following:
And also on the model that is being populated with the large file data:
Still the same error.
I would be interested to hear peoples suggestions on what could be causing my error.
I have managed to get this working eventually by adding the following to the Startup.cs file:
Code:
services.Configure<FormOptions>(x =>
{
x.ValueLengthLimit = int.MaxValue;
x.MultipartBodyLengthLimit = int.MaxValue;
x.MultipartHeadersLengthLimit = int.MaxValue;
});
services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = int.MaxValue;
});
Now I am able to load large files as expected.