Home > Back-end >  Maximum request length exceeded in DOT NETCORE MVC c#
Maximum request length exceeded in DOT NETCORE MVC c#

Time:03-22

I am working on DOT NET CORE MVC C# Project.

I am getting the error when I am trying to upload a video of size 500MB or 1GB to my site. How do I fix this?

After searching on web perform two task but still failed to upload.

Size: = MAX VIDEO SIZE 3GB

TRIED CODE

<httpRuntime maxRequestLength="SIZE_DETAILS" requestValidationMode="2.0" enableVersionHeader="false"  />

TRIED CODE

<configuration>
    <system.web>
        <httpRuntime maxRequestLength="1048576" />
    </system.web>
</configuration>

CodePudding user response:

We ran into this when passing large files from one app to another. We got it to work by doing this in our web.config inside of <system.webServer> somewhere.

<security>
    <requestFiltering>
        <requestLimits maxAllowedContentLength="1048576"
    </requestFiltering>
</security>

You'll need to do something different than 1048576 though. maxAllowedContentLength is set in bytes, so you'd need at least ~3221225472 bytes set to upload a 3GB video, so make sure you go above that.

CodePudding user response:

For 500mb videos use the code below:

<httpRuntime maxRequestLength="2147483647" />

In simple terms you even need a higher memory but for images and videos around 2.5MB this will fix it. Anything higher will require a higher maxRequestLength.

Or even increase it to something like

<httpRuntime maxRequestLength="22147483647" />

I used this to handle pictures that are higher and manipulate by reducing the image size in code and it worked.

  • Related