0

I have a .NET Core 3.1 Web API that can return large data of around 250MB. The data is coming from SQL so it cannot be referenced via hyperlinks. The client I am using is HttpClient on the calling application. It is not giving any error in response.

When it returns smaller data around 40MB, I get Status Code 200 in response. The Content-Length has some value. The await response.Content.ReadAsStringAsync() has the content.

But when it returns large data of around 150MB, I get Status Code 200 in response. The Content-Length is 0. The await response.Content.ReadAsStringAsync() has empty value.

Is there any limit on the response data size in Web API?

Reyan Chougle
  • 4,917
  • 2
  • 30
  • 57
  • HI,@Reyan Chougle , Response have not limit the size, you can use postman to test the api (change the default maximum size in postman because the default maximum size in postman is 50MB), if the postman can receive the file successfully, The problem may be the defualt limit size of file in upload file in client, You can add `[RequestFormLimits(MultipartBodyLengthLimit = 209715200)]` attribute to change the the defualt limit size of file(200MB) in client. – Xinran Shen Feb 07 '22 at 06:58
  • @XinranShen I know that the response does not have any limit. But then why I am getting empty response when server sends large data – Reyan Chougle Feb 07 '22 at 14:20
  • Because the receive file has a size limit, You can use postman to test the response first. – Xinran Shen Feb 08 '22 at 00:51
  • @XinranShen I made the changes in Postman to receive data of any size but still the same behaviour :( – Reyan Chougle Feb 09 '22 at 15:32
  • You can reference to [this](https://stackoverflow.com/questions/45948506/send-large-file-from-webapi-content-length-is-0) – Xinran Shen Feb 10 '22 at 01:01

0 Answers0