.Net Core 5.0 The size of the uploaded file through the Swagger Api is limited, report the error: error: request entity too large
Solution:
1. Add the following code in Startup
public void ConfigureServices(IServiceCollection services) { services.Configure<FormOptions>(options => { // Set the limit to 256 MB options.MultipartBodyLengthLimit = 268435456; }); }
2. Add in Program
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.ConfigureKestrel((context, options) => { // Handle requests up to 50 MB options.Limits.MaxRequestBodySize = 52428800; }) .UseStartup<Startup>(); });
3. Add the method of adding features in the operation method
// Handle requests up to 50 MB [RequestSizeLimit(52428800)] public ActionResult<ResultDto<bool>> AddFile() { ... }
Personally recommend the first one, and limit the case to the configuration file.
Read More:
- [Solved] ES Query SIZE too large Error: ENTITY CONTENT IS TOO LONG [105539255] FOR THE CONFIGURED BUFFER LIMIT [104857600]
- [Solved] nodejs Error: request entity too large
- How to Solve Nginx 413 Error (request entity too large)
- Grafana Error: 414 Request-URI Too Large [How to Solve]
- [How to Solve] java.lang.IllegalArgumentException: Request header is too large
- [Solved] Nginx Error: 400 Request Header Or Cookie Too Large
- [Solved] Browser Access Error: Request Header or Cookie too large
- [Solved] net core HTTP Error 500.31 – Failed to load ASP.NET Core runtime HTTP Error 500.30 – ASP.NET Core
- The problem of using GB2312 encoding in .NET Core to report errors
- [Solved] ELK Log System Error: “statusCode“:429,“error“:“Too Many Requests“,“message“ Data too large
- [Solved] Asp.Net Core IIS Error: HTTP Error 500.30 – ASP.NET Core app failed to start
- [Solved] swagger Error: Fetch errorInternal Server Error /swagger/v1/swagger.jso
- How to Solve Internal Server Error: /swagger/v1/swagger.json
- [Solved] Axios Error: Request body larger than maxBodyLength limit
- Error in plot.new() : figure margins too large
- [Solved] sqoop Error: jSQLException in nextKeyValue Caused by: ORA-24920:column size too large for client
- [Solved] failed to req API:localhost:8848/nacos/v1/ns/instance. code:500 msg: java.net.ConnectException
- [Solved] Error running XxlJobExecutorHiveApplication. Command line is too long. Shorten the command line via
- TensorFlow error: AttributeError: module ‘tensorflow_core._api.v2.train’ has no attribute ‘Optimizer‘
- EF core Creates pg library and Model Report an Error [Solved]