Microsoft Technologies based on the .NET software framework. Miscellaneous topics that do not fit into specific categories.
Hi @Ming Liang ,
Thanks for reaching out.
In .NET 8, NetworkInterface.GetIsNetworkAvailable() checks for active network adapters with an IP address. In .NET 9, the function was updated internally to also consider certain virtual adapters or system networks, which can make it return true even if the computer isn’t connected to the internet.
You can manually check for active, non-virtual network interfaces with a simple filter, for example:
using System.Net.NetworkInformation;
bool isNetworkReallyAvailable = NetworkInterface
.GetAllNetworkInterfaces()
.Any(ni =>
ni.OperationalStatus == OperationalStatus.Up &&
ni.NetworkInterfaceType != NetworkInterfaceType.Loopback &&
ni.NetworkInterfaceType != NetworkInterfaceType.Tunnel
);
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.