locked
How to identify that my user is/isn't connected to a VPN? RRS feed

  • Question

  • According to this page, the GetAllNetworkInterfaces() function of the NetworkInterface Class (http://msdn.microsoft.com/en-us/library/vstudio/system.net.networkinformation.networkinterface) is not available for Windows Store Apps. 

    If I observe the app with these two events, I can see that they are raised when I connect/disconnect from the VPN, but I have been unable to determine which state the app's VPN connection is in.

    NetworkChange.NetworkAddressChanged += NetworkChangeOnNetworkAddressChanged;
    NetworkInformation.NetworkStatusChanged += NetworkInformationOnNetworkStatusChanged;

    I will need to know whether I am on the VPN so that the app can intelligently switch between web service usage or cached data usage. Has anyone had any experience getting something like this to work?

    Tuesday, May 20, 2014 7:19 PM

Answers

  • Instead of testing for VPN see if you can reach the web service. If not, then use the cached data. This will continue to work even if you're on the VPN but the web service is not available.

    --Rob

    • Marked as answer by Anne Jing Thursday, May 29, 2014 3:40 AM
    Wednesday, May 21, 2014 12:03 AM
    Moderator