Export (0) Print
Expand All

ConnectivityStatus.IsOffline Property

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

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

Public Shared Property IsOffline As Boolean

Property Value

Type: System.Boolean
true if the application is in offline mode; otherwise, false.

When you set the IsOffline property, the ConnectivityStatus class caches the value to the local file system. The client service providers in the System.Web.ClientServices.Providers namespace check this value to determine whether to use the offline data cache instead of attempting to access the associated Microsoft Ajax authentication, roles, and profile services.

The following example code demonstrates how to use this property 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

Supported in: 4.6, 4.5, 4, 3.5

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft