FormsAuthentication Class

[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.]

Provides an authentication service implementation that performs Forms authentication using a DomainContext generated from a domain service implementing the IAuthentication<T> interface.

Inheritance Hierarchy

System.Object
  System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService
    System.ServiceModel.DomainServices.Client.ApplicationServices.WebAuthenticationService
      System.ServiceModel.DomainServices.Client.ApplicationServices.FormsAuthentication

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

Syntax

'Declaration
Public Class FormsAuthentication _
    Inherits WebAuthenticationService
'Usage
Dim instance As FormsAuthentication
public class FormsAuthentication : WebAuthenticationService
public ref class FormsAuthentication : public WebAuthenticationService
type FormsAuthentication =  
    class
        inherit WebAuthenticationService
    end
public class FormsAuthentication extends WebAuthenticationService

The FormsAuthentication type exposes the following members.

Constructors

  Name Description
Public method FormsAuthentication Initializes a new instance of the FormsAuthentication class.

Top

Properties

  Name Description
Public property DomainContext Gets or sets the domain context this service delegates authenticating, loading, and saving to. (Inherited from WebAuthenticationService.)
Public property DomainContextType Gets or sets the type of the domain context. (Inherited from WebAuthenticationService.)
Public property IsBusy Gets a value indicating whether an asynchronous operation is in progress. (Inherited from AuthenticationService.)
Public property IsLoadingUser Gets a value indicating whether an asynchronous LoadUser operation is in progress. (Inherited from AuthenticationService.)
Public property IsLoggingIn Gets a value indicating whether an asynchronous Login operation is in progress. (Inherited from AuthenticationService.)
Public property IsLoggingOut Gets a value indicating whether an asynchronous Logout operation is in progress. (Inherited from AuthenticationService.)
Public property IsSavingUser Gets a value indicating whether an asynchronous SaveUser operation is in progress. (Inherited from AuthenticationService.)
Protected property SupportsCancellation Gets a value that indicates whether this service supports cancellation. (Inherited from WebAuthenticationService.)
Public property User Gets a principal representing the authenticated user. (Inherited from AuthenticationService.)

Top

Methods

  Name Description
Protected method BeginLoadUser Begins an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected method BeginLogin Begins an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected method BeginLogout Begins an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected method BeginSaveUser Begins an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Protected method CancelLoadUser Cancels an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected method CancelLogin Cancels an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected method CancelLogout Cancels an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected method CancelSaveUser Cancels an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Protected method CreateDefaultUser Creates a default user. (Inherited from WebAuthenticationService.)
Protected method EndLoadUser Ends an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected method EndLogin Ends an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected method EndLogout Ends an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected method EndSaveUser Ends an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method Initialize Initializes this authentication service. (Inherited from WebAuthenticationService.)
Public method LoadUser() Asynchronously loads the authenticated user from the server. (Inherited from AuthenticationService.)
Public method LoadUser(Action<LoadUserOperation>, Object) Asynchronously loads the authenticated user from the server with specified callback method and user state. (Inherited from AuthenticationService.)
Public method Login(LoginParameters) Asynchronously authenticates and logs in to the server with the specified parameters. (Inherited from AuthenticationService.)
Public method Login(String, String) Asynchronously authenticates and logs in to the server with the specified user name and password. (Inherited from AuthenticationService.)
Public method Login(LoginParameters, Action<LoginOperation>, Object) Asynchronously authenticates and logs in to the server with the specified parameters, callback method, and user state. (Inherited from AuthenticationService.)
Public method Logout(Boolean) Asynchronously logs out an authenticated user from the server with the specified value indicating whether an exception is thrown for errors. (Inherited from AuthenticationService.)
Public method Logout(Action<LogoutOperation>, Object) Asynchronously logs out an authenticated user from the server with the specified callback method and user state. (Inherited from AuthenticationService.)
Protected method MemberwiseClone (Inherited from Object.)
Protected method OnPropertyChanged Raises a PropertyChanged event. (Inherited from AuthenticationService.)
Protected method RaisePropertyChanged Raises a PropertyChanged event for the specified property. (Inherited from AuthenticationService.)
Public method SaveUser(Boolean) Asynchronously saves the authenticated user to the server with the specified value indicating whether an exception is thrown for errors. (Inherited from AuthenticationService.)
Public method SaveUser(Action<SaveUserOperation>, Object) Asynchronously saves the authenticated user to the server with the specified callback method and user state. (Inherited from AuthenticationService.)
Public method ToString (Inherited from Object.)

Top

Events

  Name Description
Public event LoggedIn Occurs when a new user is successfully logged in. (Inherited from AuthenticationService.)
Public event LoggedOut Occurs when a user is successfully logged out. (Inherited from AuthenticationService.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate event INotifyPropertyChanged.PropertyChanged Occurs every time a property value changes. (Inherited from AuthenticationService.)

Top

Remarks

To configure your application to use Forms authentication, you must set values in both the server and client project. You use the FormsAuthentication class when setting the value in the client project.

In the Web.config file of the server project, set the authentication mode to “Forms”, as shown in the following example.

<system.web>
  <authentication mode="Forms"></authentication>
</system.web>

In the constructor of the Application object for the client application, set the Authentication property of the WebContext object to FormsAuthentication, as shown in the following example. The constructor is typically in a file named App.xaml.cs or App.xaml.vb.

Public Sub New()
    InitializeComponent()

    Dim webcontext As New WebContext
    webcontext.Authentication = New System.ServiceModel.DomainServices.Client.ApplicationServices.FormsAuthentication
    Me.ApplicationLifetimeObjects.Add(webcontext)
End Sub
public App()
{
    this.Startup += this.Application_Startup;
    this.UnhandledException += this.Application_UnhandledException;

    InitializeComponent();

    WebContext webcontext = new WebContext();
    webcontext.Authentication = new System.ServiceModel.DomainServices.Client.ApplicationServices.FormsAuthentication();
    this.ApplicationLifetimeObjects.Add(webcontext);
}

Thread Safety

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

See Also

Reference

System.ServiceModel.DomainServices.Client.ApplicationServices Namespace