If ICMP Is Blocked/Disabled by Administrator. Is there any way to check the internet connection through C# when ping test is not possible.
Thanks in Advance.
I have not tried it yet, but I think the following works.
HttpWebRequest req;
HttpWebResponse resp;
req = (HttpWebRequest)WebRequest.Create("http://www.stackoverflow.com");
resp = (HttpWebResponse)req.GetResponse();
if(resp.StatusCode.ToString().Equals("OK"))
{
Console.WriteLine("its connected.");
}
else
{
Console.WriteLine("its not connected.");
}
I think this will do the job, and it might be required to add 'System.Net' or so to the usings.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.