0
因此,我正在關注本教程:http://www.asp.net/web-api/overview/web-api-clients/calling-a-web-api-from-a-net-client,我想知道我如何查看我連接到的網站是否處於離線狀態。如何查看HttpClient是否連接到離線網站
這是我有
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:54932/");
client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = client.GetAsync("api/products").Result;
Console.WriteLine("here");
代碼當URL http://localhost:54932/
在線一切工作只是罰款,並打印here
。但是,當網站處於脫機狀態時,不會打印here
。我如何知道IP地址是否已關閉?
大非常感謝! – user3182508