Adjusting the Maximum Request Length for ASP.NET Core and ASP.NET Applications
Learn how to adjust the maximum request length for ASP.NET Core and ASP.NET applications to allow loading large files into the Document Viewer. This article shows how to configure the maximum request length in the web.config file and the KestrelServerOptions in the Program.cs file.

When making large HttpPost requests, such as uploading files or loading documents into the Document Viewer, the maximum request size is limited by default. Several settings are required in ASP.NET Core and ASP.NET applications to prepare applications to handle larger requests.
There are also differences in the hosting server depending on whether you are using .NET Kestrel or IIS. This article will cover the necessary settings for both hosting servers.
ASP.NET Core
ASP.NET Core applications have a default limit of 30MB for the maximum request size. This limit is set in the Program.cs file in the ConfigureServices method. The ConfigureServices method is where you can configure services that the application will use. The ConfigureServices method is called before the Configure method, which is where the application's request pipeline is configured.
Kestrel
To increase the maximum request size, you can use the Configure<KestrelServerOptions> method to configure the Kestrel server options. The Configure<KestrelServerOptions> method is called on the IServiceCollection interface, which is the collection of services that the application will use.
Here is an example of how to increase the maximum request size to approximately 8.59 GB:
builder.Services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = int.MaxValue;
});
IIS
If you are hosting an ASP.NET Core application in IIS, you must configure the maximum request size in web.config. The web.config file is an XML file containing application configuration settings. The web.config file is located in the application's root directory.
Here is an example of how to increase the maximum request size to the maximum value:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
</system.webServer>
ASP.NET
The maximum request size for ASP.NET applications is limited to 4 MB by default. This limit is set by your web.config file.
IIS Request Filtering
At the IIS level, the Request Filtering module is used to limit the size of data that IIS accepts. Increase the maxAllowedContentLength value, which specifies the size of the POST buffer in bytes.
The default is 30000000 bytes (28.6 MB). The maximum value is 4294967295 bytes (4 GB).
Here is an example of how to increase the maximum request size:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
</system.webServer>
HttpRuntime maxRequestLength
ASP.NET has its own setting for limiting the size of uploads and requests. Use the maxRequestLength property of the httpRuntime element.
The default size is 4096 kilobytes (4MB). The maximum value is 2,147,483,647 kilobytes (~82 terabytes). The following setting defines a maximum size of 500 megabytes.
The length of the request can be defined as follows:
<system.web>
<httpRuntime targetFramework="4.8" maxRequestLength="1048576" executionTimeout="120" />
</system.web>
These settings will allow you to handle larger requests in your ASP.NET Core and ASP.NET applications.
Conclusion
When making large HttpPost requests, such as uploading files or loading documents into the Document Viewer, the maximum request size is limited by default. Several settings are required in ASP.NET Core and ASP.NET applications to prepare applications to handle larger requests.
ASP.NET
Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.
- Angular
- Blazor
- React
- JavaScript
- ASP.NET MVC, ASP.NET Core, and WebForms
Related Posts
How to Detect and Extract Table Data as JSON from PDF Documents in C#
A common use case is to extract tabular data from tables in a PDF document to create a structured and reusable data format. This article describes how to convert tables recognized by the PDF…
Generating Hierarchical Tables from JSON Data in .NET C#
Using TX Text Control, you can generate complex hierarchical tables directly from JSON data. This article explains the code and logic behind it.
Using MailMerge Events to Remove Trailing Text in a Merge Block
Consider a repeating block that contains a comma separated list and the last comma should be removed. This article shows how to implement this functionality using MailMerge events.
Creating Invoices from DOCX Templates in C# from Scratch
This tutorial shows how to create an invoice using TX Text Control .NET Server from scratch including creating a template, merging data and to generate the resulting PDF.
Mail Merge MS Word Office Open XML (DOCX) Templates in C#
TX Text Control's MailMerge engine allows you to perform MS Word compatible mail merge processes in .NET based applications. This article gives an overview of the basic functionality and shows how…