Export (0) Print
Expand All

LogoutOperation Class

WCF RIA Services

[WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.]

Operation type returned from Logout operations on AuthenticationService.

Namespace:  System.ServiceModel.DomainServices.Client.ApplicationServices
Assembly:  System.ServiceModel.DomainServices.Client (in System.ServiceModel.DomainServices.Client.dll)

public sealed class LogoutOperation : AuthenticationOperation

The LogoutOperation type exposes the following members.

  NameDescription
Protected propertyAsyncResultGets the asynchronous result returned from BeginCore. (Inherited from AuthenticationOperation.)
Public propertyCanCancelGets a value that indicates whether this OperationBase is currently in a state that enables it to be canceled. (Inherited from OperationBase.)
Public propertyErrorGets the operation error if the operation failed. (Inherited from OperationBase.)
Public propertyHasErrorGets a value that indicates whether the operation failed. (Inherited from OperationBase.)
Public propertyIsCanceledGets a value that indicates whether this operation has been canceled. (Inherited from OperationBase.)
Public propertyIsCompleteGets a value that indicates whether this operation has completed. (Inherited from OperationBase.)
Public propertyIsErrorHandledGets or sets a value that indicates whether the operation error has been handled. (Inherited from OperationBase.)
Protected propertyResultGets the result as an AuthenticationResult. (Inherited from AuthenticationOperation.)
Protected propertyServiceGets the service this operation will use to implement Begin, Cancel, and End. (Inherited from AuthenticationOperation.)
Protected propertySupportsCancellationGets a value that indicates whether the operation supports cancellation. (Inherited from AuthenticationOperation.)
Public propertyUserGets the user principal. (Inherited from AuthenticationOperation.)
Public propertyUserStateGets the optional user state for this operation. (Inherited from OperationBase.)
Top

  NameDescription
Protected methodBeginCoreInvokes the corresponding Begin method in the underlying asynchronous result implementation. (Inherited from AuthenticationOperation.)
Public methodCancelCancels the operation. (Inherited from OperationBase.)
Protected methodCancelCoreWhen overridden in a derived class, provides the logic to cancel the operation. (Inherited from OperationBase.)
Protected methodComplete(Exception)Completes a failed operation with the specified error. (Inherited from OperationBase.)
Protected methodComplete(Object)Completes a successful operation with the specified result. (Inherited from OperationBase.)
Protected methodEndCoreInvokes the corresponding End method in the underlying asynchronous result implementation. (Inherited from AuthenticationOperation.)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodInvokeCompleteActionInvokes the completion callback. (Inherited from OperationBase.)
Public methodMarkErrorAsHandledSpecifies that an error encountered in an operation is handled. (Inherited from OperationBase.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodOnPropertyChangedCalled when the value of a property changes. (Inherited from OperationBase.)
Protected methodRaiseCompletionPropertyChangesRaises property changes after the operation has completed. (Inherited from AuthenticationOperation.)
Protected methodRaisePropertyChangedRaises the System#ComponentModel#INotifyPropertyChanged#PropertyChanged() event. (Inherited from OperationBase.)
Public methodToString (Inherited from Object.)
Top

  NameDescription
Public eventCompletedOccurs when the operation completes. (Inherited from OperationBase.)
Top

  NameDescription
Explicit interface implemetationPrivate eventINotifyPropertyChanged.PropertyChangedOccurs when a property value changes. (Inherited from OperationBase.)
Top

The following example shows a call to the Logout method with callback method that accepts a LogoutOperation object as a parameter.

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    SetControlVisibility(WebContext.Current.User.IsAuthenticated);
}

private void LoginButton_Click(object sender, RoutedEventArgs e)
{
    LoginParameters lp = new LoginParameters(UserName.Text, Password.Password);
    WebContext.Current.Authentication.Login(lp, this.LoginOperation_Completed, null);
    LoginButton.IsEnabled = false;
    LoginResult.Text = "";
}

private void LoginOperation_Completed(LoginOperation lo)
{
    if (lo.HasError)
    {
        LoginResult.Text = lo.Error.Message;
        LoginResult.Visibility = System.Windows.Visibility.Visible;
        lo.MarkErrorAsHandled();
    }
    else if (lo.LoginSuccess == false)
    {
        LoginResult.Text = "Login failed. Please check user name and password.";
        LoginResult.Visibility = System.Windows.Visibility.Visible;
    }
    else if (lo.LoginSuccess == true)
    {
        SetControlVisibility(true);
    }
    LoginButton.IsEnabled = true;
}

private void SetControlVisibility(bool isAuthenticated)
{
    if (isAuthenticated)
    {
        LoginBorder.Visibility = System.Windows.Visibility.Collapsed;
        WelcomeText.Text = "Welcome " + WebContext.Current.User.Name;
        WelcomeText.Visibility = System.Windows.Visibility.Visible;
        LogoutButton.Visibility = System.Windows.Visibility.Visible;
    }
    else
    {
        LoginBorder.Visibility = System.Windows.Visibility.Visible;
        WelcomeText.Visibility = System.Windows.Visibility.Collapsed;
        LogoutButton.Visibility = System.Windows.Visibility.Collapsed;
    }
}

private void LogoutButton_Click(object sender, RoutedEventArgs e)
{
    WebContext.Current.Authentication.Logout(this.LogoutOperation_Completed, null);
}

private void LogoutOperation_Completed(LogoutOperation lo)
{

    if (!lo.HasError)
    {
        SetControlVisibility(false);
    }
    else
    {
        ErrorWindow ew = new ErrorWindow("Logout failed.", "Please try logging out again.");
        ew.Show();
        lo.MarkErrorAsHandled();
    }
}


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