Share via

GetIsNetworkAvailable() behaves differently depending on NET version on Win11 LTSC.

Ming Liang 61 Reputation points
2026-02-06T01:06:29.3+00:00

we have a project using the following function call.

On a Win11 LTSC test unit with no network connection:

Project built with NET 8.0,  function GetIsNetworkAvailable() returns false

Project built with NET 9.0,  function GetIsNetworkAvailable() returns true

  var isNetworkAvailable = NetworkInterface.GetIsNetworkAvailable();

Why GetIsNetworkAvailable() behaves differently? How to make GetIsNetworkAvailable() returns false when the project is built with NET 9.0? Thanks.

Developer technologies | .NET | Other
0 comments No comments
{count} votes

Answer accepted by question author
  1. Jack Dang (WICLOUD CORPORATION) 14,960 Reputation points Microsoft External Staff Moderator
    2026-02-06T09:07:36.7233333+00:00

    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.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.