ConnectivityStatus Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Represents the status of an application's network connection.

Namespace:   System.Web.ClientServices
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)


Public NotInheritable Class ConnectivityStatus


Gets or sets a value indicating whether an application is in offline mode.

Use the ConnectivityStatus class to specify the network connectivity of Windows-based applications that use client application services. When you set the IsOffline property to true, the client service providers use the offline cache instead of attempting to access the corresponding Web services. The offline status is stored on a per-user and per-application basis. For more information, see How to: Work Offline with Client Application Services.

The following example code demonstrates how to use this class to update the offline status depending on a check box value. In this example, a CheckedChanged event handler updates the offline status. If the user sets the application to the online state, the event handler attempts to revalidate the user. However, if the authentication server is unavailable, the event handler returns the application to the offline state.

Private Sub workOfflineCheckBox_CheckedChanged( _
    ByVal sender As Object, ByVal e As EventArgs) _
    Handles workOfflineCheckBox.CheckedChanged

    ConnectivityStatus.IsOffline = workOfflineCheckBox.Checked
    If Not ConnectivityStatus.IsOffline Then


            ' Silently re-validate the user.
            CType(System.Threading.Thread.CurrentPrincipal.Identity,  _

            ' If any settings have been changed locally, save the new
            ' new values to the Web settings service.

            ' If any settings have not been changed locally, check 
            ' the Web settings service for updates. 

        Catch ex As System.Net.WebException

            MessageBox.Show( _
                "Unable to access the authentication service. " & _
                Environment.NewLine + "Staying in offline mode.", _
                "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning)
            workOfflineCheckBox.Checked = True

        End Try

    End If
End Sub

.NET Framework
Available since 3.5

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top