How to handle HTTP Status = 0?

winanjaya 146 Reputation points
2023-09-28T01:44:56.22+00:00

Hi

Our ASP.NET Core 6 Web API consume a 3rd party Web API, sometimes we get http status 0 and I don't know what does it mean?, I have tried to handle this using Polly but it doesn't arrive there?

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

if (httpRes.IsSuccessStatusCode) 
{     
    string _res = httpRes.Content.ReadAsStringAsync().Result;

    // some tasks 
}

await Models.Tokens.Log.UpdateAsync(tokensPid, iStatusCode);									

Polly:

	
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.