Quote:
note that I can access the internet through an ISA server 2006 and can't connect my computer directly to the router
In such cases you can only use protocols that are allowed (forwarded) by the server. For ping this requires that outgoing ICMP packets and the corresponding responses are not filtered. You might ask the administrator of the ISA server about this.
You can't ping a website. The parameter for the
Ping()
function must be an IP address, an URL like
www.example.com, or a computer name of a system in your local network.
See also
Network.Ping Method (Microsoft.VisualBasic.Devices) | Microsoft Docs[
^]:
Quote:
The Ping method is not a fail-safe method for determining the availability of a remote computer: the ping port on the target computer may be turned off or the ping request may be blocked by a firewall or router.
The address passed to the Ping method must be DNS resolvable and cannot be preceded by "http://".
That means that you might get no response even when ICMP ping packets are not filtered by the ISA server.
Quote:
I'm doing a small program for testing network connectivity
Depending on what you mean by "network connectivity" this can be done by other methods:
Check the status of your systems network interface (
NetworkInterface.OperationalStatus Property (System.Net.NetworkInformation) | Microsoft Docs[
^]).
Perform a name resolution using
Dns.GetHostEntry Method (System.Net) | Microsoft Docs[
^] with a valid name. This will check the connection to one of the DNS resolvers configured for your network interface. This might be either the ISA server, the router, or a DNS server in the net and tells you so if connectivity to that system is present.
For internet connectivity (which would be a problem of the ISA server or router if not available) try to connect to a service like HTTP of a known server that is not blocked by the ISA server.
[EDIT]
There is also a Windows API function returning the connection state:
INetworkListManager::GetConnectivity | Microsoft Docs[
^]
Unfortunately there seems to be no .Net equivalent. But the web should provides examples on how to call it from .Net like
How to use the Windows NLM API to get notified of new network connectivity[
^].
[/EDIT]