I cannot seem to catch HttpRequestException or any exception for that matter when sending request to a nonexistent endpoint.
http://localhost:8030/ does not exist, however I should be able to catch HttpRequestException in try/catch block. What am I missing ?
Uri address = new Uri("http://localhost:8030/");
HttpClient client = new HttpClient();
var rm = new HttpRequestMessage()
{
Method = HttpMethod.Post,
RequestUri = address
};
try
{
var response = await client.SendAsync(rm);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw;
}