locked
How to check the Internet connectivity?

    Question

  • Hi,
    I'm developing Windows Phone 8.1 App.
    This is a kind of messaging app. So, I want to check the user internet connection and want to validate it.
    Please help me in this regard.
    Monday, March 16, 2015 1:12 PM

Answers

  • You can use NetworkInterface.GetIsNetworkAvailable() method. It returns true if network connection is available and false if not. And don't forget to add using Microsoft.Phone.Net.NetworkInformation or using System.Net.NetworkInformation if you are in PCL.

    Monday, March 16, 2015 1:29 PM
  • Hi,You can use following code to check internet connection available or not.

    add nmaespace-> using System.Net.NetworkInformation; 

    if (NetworkInterface.GetIsNetworkAvailable() == true)
                {
                    System.Diagnostics.Debug.WriteLine("Internet Available");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Internet not Available");
                }

    For more details find following link,

    https://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getisnetworkavailable(v=vs.110).aspx

    Don't forget to mark the right answer and vote up if helps you.

    Tuesday, March 17, 2015 6:59 AM

All replies

  • You can use NetworkInterface.GetIsNetworkAvailable() method. It returns true if network connection is available and false if not. And don't forget to add using Microsoft.Phone.Net.NetworkInformation or using System.Net.NetworkInformation if you are in PCL.

    Monday, March 16, 2015 1:29 PM
  • Hi

    windows phone 8.1 apis for network connectivity .Please refer the following msdn article.

    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh452991.aspx

    Regards



    Varun Ravindranath Please 'Mark as Answer' if my post answers your question and 'Vote as Helpful' if it helps you.


    Monday, March 16, 2015 5:32 PM
  • Hi,You can use following code to check internet connection available or not.

    add nmaespace-> using System.Net.NetworkInformation; 

    if (NetworkInterface.GetIsNetworkAvailable() == true)
                {
                    System.Diagnostics.Debug.WriteLine("Internet Available");
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Internet not Available");
                }

    For more details find following link,

    https://msdn.microsoft.com/en-us/library/system.net.networkinformation.networkinterface.getisnetworkavailable(v=vs.110).aspx

    Don't forget to mark the right answer and vote up if helps you.

    Tuesday, March 17, 2015 6:59 AM