Why I get http status code = 0

winanjaya 146 Reputation points
2023-10-15T10:43:07.7533333+00:00

Hi,

Why I get http status code = 0 in my case iStatusCode occasionally?, what I missed from my codes below?

ASP.NET Core 6

 HttpResponseMessage httpRes = _httpClient.GetAsync(url).Result;
 iStatusCode = (int)httpRes.StatusCode;

 if (httpRes.IsSuccessStatusCode)
 {
     string _res = httpRes.Content.ReadAsStringAsync().Result;
Developer technologies ASP.NET ASP.NET Core
Developer technologies C#
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.