Horje
c# how to check for internet connectivity Code Example
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;
    }
}




Csharp

Related
unity deactive all object in list Code Example unity deactive all object in list Code Example
count number of specific characters in string c# Code Example count number of specific characters in string c# Code Example
datetime empty date Code Example datetime empty date Code Example
System.Data.Entity.Core.EntityException: The underlying provider failed on Open Code Example System.Data.Entity.Core.EntityException: The underlying provider failed on Open Code Example
How can I display image from database in asp.net mvc. I created image table and image path as varchar Code Example How can I display image from database in asp.net mvc. I created image table and image path as varchar Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8