How to check your internet connection over the internet?

I am developing one software for which I want to check whether the computer that uses my software that has an Internet connection is used to achieve the desired goal. I use web services and web services running on the admin side, which is located on the remote machine, using the fact that I allow the user to access the remote database. And it should work on all types of Internet connections, such as LAN, WiFi, Dialup, or whatever the user uses.

How to do it?

I need one service from all of you. If I used the following code, will it fulfill all my requirements or not?

using Microsoft.VisualBasic.Devices; Computer oComputer = new Computer(); if (oComputer.Network.IsAvailable == true) { MessageBox.Show("Internet connection available"); } else { MessageBox.Show("Internet connection not available"); } 

thanks.

+1
source share
3 answers

System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable() should get what you want.

+3
source

An effective way to test your Internet connection is to use the InternetGetConnectedState() WinAPI. But if you have your own web service that you are trying to connect to, you can always add a helper ping method to the service, which returns a boolean true if everything is ok.

0
source

Someone asked a simillar question, you should have checked it before asking a question.

0
source

Source: https://habr.com/ru/post/1379875/


All Articles