How to increase the max upload file size in ASP.NET?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Increasing upload size in ASP.NET is not a single setting. The effective limit usually depends on the application framework, the hosting server, and sometimes request buffering behavior in the upload code itself. The correct fix is to change the size limits in the layer that is actually rejecting the request.
First Identify Which ASP.NET Stack You Are Using
There are two common cases:
- ASP.NET Framework running under IIS with
web.config - ASP.NET Core using Kestrel, IIS, or both
The configuration style is different between them, so copying random examples often leads to changing the wrong setting.
ASP.NET Framework Under IIS
In classic ASP.NET Framework applications, the two most common limits are:
- '
httpRuntime maxRequestLengthin kilobytes' - IIS
requestLimits maxAllowedContentLengthin bytes
A typical web.config setup for roughly 500 MB looks like this:
If one of these is smaller than the other, the smaller one wins. That is why changing only httpRuntime sometimes appears to do nothing.
ASP.NET Core with Kestrel
ASP.NET Core uses different APIs. If the app is hosted with Kestrel, request size can be configured in code.
If you only set Kestrel but your app is behind IIS or another proxy that enforces a smaller limit first, the upload still fails upstream.
ASP.NET Core Multipart Form Limits
File uploads often arrive as multipart form data, which may have their own limit settings. In ASP.NET Core, you can adjust form options like this:
This matters because large uploads can fail at the form parsing stage even if the server's raw request limit was increased.
IIS and Reverse Proxy Considerations
If ASP.NET Core is hosted behind IIS, IIS can reject the request before it reaches your application. In that case you still need the IIS-side request limit configured appropriately.
So a realistic troubleshooting order is:
- check the application framework settings
- check IIS request filtering if IIS is involved
- check any reverse proxy or load balancer limits
- confirm the request is not timing out during slow uploads
If you skip the hosting layer, you often end up increasing a limit that the request never reaches.
Keep the Upload Path Reasonable
Raising the limit is only half the job. Large uploads have operational consequences:
- more memory pressure if buffering is used
- longer request times
- more risk from abusive uploads
- more need for virus scanning and content validation
If files are very large, consider streaming them directly to disk or object storage instead of buffering everything in memory.
Common Pitfalls
A common mistake is changing only one limit and assuming the upload path has only one choke point. IIS, ASP.NET, and multipart parsing can all enforce limits.
Another mistake is copying an ASP.NET Framework web.config solution into an ASP.NET Core app and expecting it to control Kestrel behavior.
People also often forget timeouts. A larger allowed size does not help if the request times out before the upload finishes.
Finally, do not raise upload limits without validating file type, size, and destination handling. Bigger uploads increase attack surface.
Summary
- The effective upload limit in ASP.NET usually comes from several layers, not one setting
- ASP.NET Framework commonly needs both
maxRequestLengthand IISmaxAllowedContentLength - ASP.NET Core commonly needs Kestrel or form limits adjusted in code
- If IIS or another proxy is in front, its request limit can reject the upload before the app sees it
- Large uploads should be paired with streaming, validation, and sensible timeout settings
- Change the limit in the layer that is actually rejecting the request, not just the first example you find
Related reading
- How to initialize a ListT to a given size as opposed to capacity?
- How to inject Javascript in WebBrowser control?
- How to install a windows service programmatically in C?
- How to interrupt Console.ReadLine
- How to invoke async-operation on two-way bound Combobox WPF
- How to keep a .NET console app running?
- How to know if a DateTime is between a DateRange in C
- How to limit memory size for .net core application in pod of kubernetes?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.