The default maximum file upload size for IIS is 4MB. Uploading more than 4MB file will give an error "Maximum request length exceeded".
machine.config file is set to 4MB default limit. We can change it using the following code in the web.config.
< system.web >
< httpRuntime executionTimeout="240" maxRequestLength="20480" / >
< /system.web >
For IIS 7 and later versions, we can modify the default upload limit. You will need to add the following code to the web.config.
< system.webServer >
< security >
< requestFiltering >
< requestLimits maxAllowedContentLength="3000000000" / >
< /requestFiltering >
< /security >
< /system.webServer >
maxAllowedContentLength is estimated in bytes
maxRequestLength is estimated in kilobytes.
default value for maxRequestLength is 4096 (4mb). max value is 2,147,483,647
default value for maxAllowedContentLength is 30,000,000 (around 30mb). max value is 4,294,967,295.
you can set value based on your file size. above maxRequestLength value is 20MB and maxAllowedContentLength 30MB. also do not forget to set the execution timeout or connectionTimeout value.
connectionTimeout specifies the time (in seconds) that IIS waits before it disconnects a connection that is considered inactive.
executionTimeout specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET.
Reference link:
https://learn.microsoft.com/en-us/iis/configuration/system.applicationHost/sites/siteDefaults/limits#005
https://learn.microsoft.com/en-us/previous-versions/dotnet/netframework-4.0/e1f13641(v=vs.100)?redirectedfrom=MSDN#Anchor_0