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