简体   繁体   English

ASP.NET Core 3.0 上 WebAPI 响应的最大长度

[英]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.我的控制器的一项操作在 JSON 响应中返回大量集合,当我向此 controller WebAPI 发出请求时,不返回响应。 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.最后,我确信这是 WebApi 的问题,因为我已经通过几个客户端(WPF 和 Postman)测试了这个控制器的操作,每个客户端都在等待响应。 I think that the obstacle is the response size of my WebAPI.我认为障碍是我的 WebAPI 的响应大小。 My WebAPI runs on IIS Express我的 WebAPI 在 IIS Express 上运行

So I have two questions:所以我有两个问题:

1). 1)。 What is the maximal size length of WebAPI response on ASP.NET Core 3.0? ASP.NET Core 3.0 上的 WebAPI 响应的最大长度是多少?
2). 2)。 How to increase maximal size length of WebAPI response on ASP.NET Core 3.0?如何在 ASP.NET Core 3.0 上增加 WebAPI 响应的最大长度?

According to documentation.根据文档。 Deafult Response buffer size is 64KB.默认响应缓冲区大小为 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>();

I came here looking for a solution to the same problem, but for me it was not resolved by changing the MaxResponseBufferSize.我来这里是为了寻找相同问题的解决方案,但对我来说,这并没有通过更改 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.事实证明,Postman 似乎也返回了同样的错误,因为可以配置最大大小,默认值为 50Mb。

In the Postman application, you can go to settings, and configure this to be 0 (unlimited), or whatever value you need.在 Postman 应用程序中,您可以 go 进行设置,并将其配置为 0(无限制)或您需要的任何值。 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM