HttpRequestException Error Handling
It says the target actively refused it. It's because I didn't launch my API. Therefore it cannot request something and gives me this error.
If we put try catch aside for a minute, is there a nice way to just skip these codes if it refuses? I will send empty lists to the client and just say "Sorry, we are having some technical issues." or something.
6 Replies
It was not giving me any error while using
HttpClient _httpClient
. It started after using IHttpClientFactory httpClientFactory
If it's an API, you need to respond with appropriate error codes for sure.
yeah, but it doesn't go into api in the first place. Try catch can easily do that but i am trying to learn alternatives
string raw = await _httpClient.GetStringAsync("posts");
For example.
(still up to date)Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I was just asking for a method and concept. There is no issue at all. As I said, I don't launch the web api, it's a choice. That's why it gives me error.
I am asking this to be able to give something to the client even if no data comes
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View