26 lines
878 B
C#
26 lines
878 B
C#
|
namespace Cloud.Support;
|
||
|
|
||
|
public static class NetworkSupport
|
||
|
{
|
||
|
public static async Task CheckConnectionAsync(string address)
|
||
|
{
|
||
|
using var client = new HttpClient();
|
||
|
try
|
||
|
{
|
||
|
var response = await client.GetAsync(address);
|
||
|
|
||
|
if (response.IsSuccessStatusCode)
|
||
|
{
|
||
|
Console.WriteLine($"Соединение успешно проверено. Статус-код: {response.StatusCode}");
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Console.WriteLine($"Соединение не удалось проверить. Статус-код: {response.StatusCode}. URL: {address}");
|
||
|
}
|
||
|
}
|
||
|
catch (HttpRequestException ex)
|
||
|
{
|
||
|
Console.WriteLine($"Ошибка при проверке соединения: {ex.Message}. URL: {address}");
|
||
|
}
|
||
|
}
|
||
|
}
|