Reputation: 169
MaxRequestBodySize is not working when its deployed to webserver with Azure App Service but it works in my local. I tried with the below changes in program.cs and startup.cs of my .net core 3.1 but none of them worked. Still getting 413 (Request Entity Too Large) error.
Program.cs:
1. webBuilder.ConfigureKestrel(serverOptions =>
{
serverOptions.Limits.MaxRequestBodySize = long.MaxValue;
})
2. .UseKestrel(options =>
{
options.Limits.MaxRequestBodySize = long.MaxValue;
}
Startup.cs
services.Configure<IISServerOptions>(options => options.MaxRequestBodySize = long.MaxValue);
Upvotes: 6
Views: 6815
Reputation: 171
Go to the kudu console of your web app (https://{your-website-name}.scm.azurewebsites.net/). Click on Debug Console dropdown in the menu and choose CMD. You will see your web app directory structure listed below. Use the list interface to navigate to site > wwwroot. Scroll down to the bottom till you come across the web.config file. Click on the edit icon on the left of the file which will open the file in an editor. Add the following lines under <system.webServer>:
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="4294967295" />
</requestFiltering>
</security>
This sets the maximum request length to 4 GB. Close the kudu console and restart your application from azure portal. Then try again.
Upvotes: 11