c# check internet connection easy
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
c# check internet connection easy
System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable()
c# how to check for internet connectivity
public static bool CheckForInternetConnection(int timeoutMs = 10000, string url = null)
{
try
{
url ??= CultureInfo.InstalledUICulture switch
{
{ Name: var n } when n.StartsWith("fa") => // Iran
"http://www.aparat.com",
{ Name: var n } when n.StartsWith("zh") => // China
"http://www.baidu.com",
_ =>
"http://www.gstatic.com/generate_204",
};
var request = (HttpWebRequest)WebRequest.Create(url);
request.KeepAlive = false
request.Timeout = timeoutMs;
using var response = (HttpWebResponse)request.GetResponse();
return true;
}
catch
{
return false;
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us