Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maximal size length of WebAPI response on ASP.NET Core 3.0

One of my controller's action returns huge collection in JSON response and when I make a request toward this controller WebAPI don't return a response. So I have tested this action using breakpoint and collection is filled normally. At the end I am sure that this is a problem of WebApi since I have tested this controller's action through several clients(WPF and Postman) and each one just hangs on waiting for a response. I think that the obstacle is the response size of my WebAPI. My WebAPI runs on IIS Express

So I have two questions:

1). What is the maximal size length of WebAPI response on ASP.NET Core 3.0?
2). How to increase maximal size length of WebAPI response on ASP.NET Core 3.0?

like image 479
Allaev Bekzod Avatar asked Oct 18 '25 03:10

Allaev Bekzod


2 Answers

I came here looking for a solution to the same problem, but for me it was not resolved by changing the MaxResponseBufferSize.

As it turned out, it seems that Postman also returns this same error, as the maximum size can be configured, and the default is 50Mb.

In the Postman application, you can go to settings, and configure this to be 0 (unlimited), or whatever value you need. enter image description here

like image 129
Allie Avatar answered Oct 20 '25 18:10

Allie


In .NET 6 & 7 you can set the response buffer by having this line of code in Program.cs before calling the builder.Build(); method

builder.WebHost.ConfigureKestrel(serverOptions =>
{
    serverOptions.Limits.MaxResponseBufferSize = null;
});

By setting the MaxResponseBufferSize to null, the size of the response buffer is unlimited as mentioned here

like image 28
j4jada Avatar answered Oct 20 '25 18:10

j4jada



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!