Reputation: 549
I have a windows phone runtime app that uses the HttpClient to make web request. How can I handle a connection exception (no internet).
Thanks
Upvotes: 0
Views: 1771
Reputation: 1560
First thing you can do before Http request:
using Microsoft.Phone.Net.NetworkInformation;
private void CheckInetConnection()
{
if (NetworkInterface.GetIsNetworkAvailable() == true)
{
//Internet avalaible
}
else
{
//No connection available
}
}
and for exception handling of HttpClient check this
response.StatusCode will give you the status of response.
Upvotes: 4