by Stian

WP7 Dev: Check for internet connection

HTC TrophyJust wanted to post a the source code for developers wanting to check for an internet connection on Windows Phone 7.
Please remember that the emulator will always return true!

Btw: I have a HTC Trophy with WP7 in my hand – it’s awesome!
private bool HasNetwork()
if (!NetworkInterface.GetIsNetworkAvailable())
MessageBox.Show("No internet connection is available. Try again later.");
return false;
return true;