Problem with ReadAsStringAsync

AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

Hi friends.
I read data (with PostAsync) from a WS.
It works with a lot of WS but now I have a WS that returns a lot of data (170000 characters).
When I call

            response = await httpClient.PostAsync(url, httpContent);

            if (response != null && response.IsSuccessStatusCode)
            {
                string s = response.Content.ReadAsStringAsync().Result;
            }

the "s" have not all data. It seems that ReadAsStringAsync terminate too fast.

How can I solve this problem?

Let me know if you need more informations

Posts

  • seanydaseanyda GBMember ✭✭✭✭✭

    Try await it and see if it helps

      response = await httpClient.PostAsync(url, httpContent);
    
                if (response != null && response.IsSuccessStatusCode)
                {
                    string s = await response.Content.ReadAsStringAsync();
                }
    
  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    It's ok. It's a my mistake.
    Thanks Sean

Sign In or Register to comment.