Failed to read the request form. Request body too large. The max request body size is 30000000 bytes #48708
-
We're stuck on making .NET accept big file uploads. We develop on Linux, deploy inside containers, and run behind Nginx reverse proxy. We develop using In the development environment we do not have a We have already added these lines to our
But it seems that this is not enough. In our development environment, we do not have a
But we got this error:
We can use per action configuration as follow, and it works.
But we want to enable large file upload for all of our APIs. How should we do it? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Could you try configuring API Docs: KestrelServerOptions It looks like |
Beta Was this translation helpful? Give feedback.
-
All of the information with code samples are on this page: https://learn.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-7.0 Here's how you tweak the limit in Kestrel: It's not showing the WebApplicationBuilder pattern: builder.WebHost.ConfigureKestrel(options =>
{
options.Limits.MaxRequestBodySize = A big number; // Maybe avoid int.MaxValue
}); |
Beta Was this translation helpful? Give feedback.
Could you try configuring
Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerOptions
instead?API Docs: KestrelServerOptions
It looks like
KestrelServerOptions
actually used be in theMicrosoft.AspNetCore.Server.Kestrel
namespace back in ASP.NET Core 1.1, but has since been moved toMicrosoft.AspNetCore.Server.Kestrel.Core
. That old version of the docs is the first search result I'm getting for "KestrelServerOptions" on Google, which is a bit confusing.