.NET MAUI › Networking & APIs

How do you check network connectivity before making a request?

Beginner

Answer

Query Connectivity.Current.NetworkAccess (Internet, Local, None) and optionally ConnectionProfiles (WiFi, Cellular). Subscribe to ConnectivityChanged to react to changes. Use it to skip requests, show offline UI, or defer syncing on metered connections.
if (Connectivity.Current.NetworkAccess != NetworkAccess.Internet)
{
    await DisplayAlert("Offline", "Check your connection.", "OK");
    return;
}
Real-world example Before syncing large data, an app warns the user and waits when only cellular or no connection is available.

Common follow-ups: What is ConnectivityChanged? | How do you detect metered connections?