Maximum request length exceeded.

When working with file uploads or large data submissions in ASP.NET, you may encounter the "Maximum Request Length Exceeded" error. This error occurs when the size of the incoming HTTP request exceeds the configured limit in the web.config file.

To address this issue, you can adjust the maxRequestLength attribute in the <httpRuntime> section of the web.config file. This attribute specifies the maximum file upload size in kilobytes. Here is an example of how you can increase the limit to 100MB (100,000 KB):

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="100000" />
  </system.web>
</configuration>
Additionally, you can also set the executionTimeout attribute to prevent timeouts during large file uploads. This attribute specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET. Here is an example of setting the timeout to 5 minutes:

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="100000" executionTimeout="300" />
  </system.web>
</configuration>
Moreover, if you are using ASP.NET MVC, you can also decorate your controller action methods with the [ValidateInput(false)] attribute to disable request validation for a specific action method. This can be useful when dealing with large form submissions.

By adjusting these settings in the web.config file and potentially disabling request validation for specific actions, you can effectively handle the "Maximum Request Length Exceeded" error in your ASP.NET application.

Nitya SinghReply

This is very helpful for me .

Surya Prakash (Admin) Reply

Thanks Nitya.

Leave a Reply

Your email address will not be published. Required fields are marked *


Talk to us?

Post your blog

F.A.Q

Frequently Asked Questions