Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ConnectivityStatus Class

Represents the status of an application's network connection.

System.Object
  System.Web.ClientServices.ConnectivityStatus

Namespace:  System.Web.ClientServices
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)
public static class ConnectivityStatus

The ConnectivityStatus type exposes the following members.

  NameDescription
Public propertyStatic memberIsOfflineGets or sets a value indicating whether an application is in offline mode.
Top

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 void workOfflineCheckBox_CheckedChanged(
    object sender, EventArgs e)
{
    ConnectivityStatus.IsOffline = workOfflineCheckBox.Checked;
    if (!ConnectivityStatus.IsOffline)
    {
        try
        {
            // Silently re-validate the user.
            ((ClientFormsIdentity)
                System.Threading.Thread.CurrentPrincipal.Identity)
                .RevalidateUser();

            // If any settings have been changed locally, save the new 
            // new values to the Web settings service.
            SaveSettings();

            // If any settings have not been changed locally, check  
            // the Web settings service for updates. 
            Properties.Settings.Default.Reload();
        }
        catch (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;
        }
    }
}

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5

Windows Phone 8.1, Windows Phone 8, 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.