Reputation: 159
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?
Upvotes: 3
Views: 22239
Reputation: 722
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
Upvotes: 3
Reputation: 1179
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.
Upvotes: 10
Reputation: 2970
According to documentation. Deafult Response buffer size is 64KB. Take a look here
You can change it like:
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args).ConfigureKestrel(x => x.Limits.MaxResponseBufferSize = yourSize)
.UseStartup<Startup>();
Upvotes: 1