Uploading large files in ASP.NET Options

codeling 1264 - 5430
@2019-12-26 14:19:37

When you try to upload files to the Web server in a ASP.NET web application, the default maximum file size is 4096 KB (4 MB). If you want to upload files larger than 4MB, you need to add the following setting in Web.config.

<configuration>
    <system.web>
        <!-- max upload file size is 30mb(30720KB) -->
        <httpRuntime requestValidationMode="2.0"  maxRequestLength="30720"/>
    </system.web>
</configuration>

otherwise, you will see the following message thrown from the application:

"System.Web.HttpException: Maximum request length exceeded" 
 

codeling 1264 - 5430
@2020-09-02 19:53:19

When you try to upload files to the Web server in a ASP.NET web application, sometimes you may see the following error:

Request timed out.

This is because the request timeout duration is 110 seconds by default, to increase this timeout value to allow for larger file uploads, you can do it by setting the executionTimeout value for httpRuntime element in the Web.config file:

<configuration>
    <system.web>
        <!-- max upload file size is 30mb(30720KB), the timeout is 6 minutes -->
        <httpRuntime requestValidationMode="2.0"  maxRequestLength="30720" executionTimeout="360"/>
    </system.web>
</configuration>

Note: This time-out applies only if the debug attribute in the <compilation> element is set to false.

 

 

Users browsing this topic
Guest