[Fixed] Failed to read the request form. Request body too large. The max request body size is 30000000 bytes – C#

by
Ali Hasan
asp.net-core-6.0 c#

Quick Fix: Add options.Limits.MaxRequestBodySize = 50 * 1024 * 1024; to your code to increase the maximum request body size allowed by Kestrel. This will allow your application to handle larger requests.

The Problem:

An ASP.NET Core API is encountering an error when attempting to process large file uploads. Despite configuring the FormOptions to increase the maximum request body size, the API continues to return a "Failed to read the request form. Request body too large. The max request body size is 30000000 bytes" error. The API is running behind an Nginx reverse proxy, and it is unclear whether this configuration is contributing to the issue.

Q&A

How to resolve the error after changing the ConfigureKestrel option and what should be replaced?

Resolving the error using ConfigureKestrel option may require changing Limits.MaxRequestBodySize to a specific size in byte.

What is the default max request body size?

The default max request body size is 30000000 bytes.

Video Explanation:

The following video, titled "2 ways to reduce your Power BI dataset size and speed up refresh ...", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

Adam shows you two things to reduce your Power BI dataset size. These are both things he commonly sees with Power BI reports and could ...