I have the code below. Running it locally I get the response back from the API in under 1 second.
When I deploy it to a server, it's taking anywhere between 3 and 10 minutes to get the response!
I've deployed to 3 different servers with the same result. Any idea what might be wrong?
Below is my code:
string response = string.Empty; try { var content = new StringContent(JsonConvert.SerializeObject(request), System.Text.Encoding.UTF8, "application/json"); using (var client = new HttpClient()) { var responseMessage = client.PostAsync("https://myapi/createshorturl", content).Result; response = responseMessage.Content.ReadAsStringAsync().Result; return JsonConvert.DeserializeObject<CreateShortUrlResponse>(response); } } catch (Exception x) { return null; }
catch (Exception x) { return null;}??? Are you sure you aren't receiving a lot of exceptions that are simply covered up?