
Solution for ASP.NET (.NET Framework)
In your web.config, increase the maxRequestLength value under <httpRuntime>. Open web.config file in your project and find maxRequestLength or httpRuntime tag.
<configuration>
<system.web>
<httpRuntime maxRequestLength="10240" executionTimeout="3600" />
</system.web>
</configuration>- maxRequestLength is in KB.
- For Example:
- 10240 = 10 MB
- 51200 = 50 MB
- 102400 = 100 MB
If you're using IIS 7+, then you also need to increase the IIS request limit.
XML:
<configuration>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600" />
</requestFiltering>
</security>
</system.webServer>
</configuration>- maxAllowedContentLength is in bytes.
- 104857600 = 100 MB
Solution for ASP.NET Core
In ASP.NET Code, the configuration is different. For example, in Program.cs,
builder.Services.Configure<IISServerOptions>(options =>
{
options.MaxRequestBodySize = 104857600; // 100 MB
});If you are still getting the error, then check...
- if the upload file size is not larger than the configured limits.
- IIS requestFiltering settings are updated.
- Restart the application or IIS after changing web.config if the changes are not picked up automatically.
