Export (0) Print
Expand All

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

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

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

public class FormsAuthentication : WebAuthenticationService

The FormsAuthentication type exposes the following members.

  NameDescription
Public methodFormsAuthenticationInitializes a new instance of the FormsAuthentication class.
Top

  NameDescription
Public propertyDomainContextGets or sets the domain context this service delegates authenticating, loading, and saving to. (Inherited from WebAuthenticationService.)
Public propertyDomainContextTypeGets or sets the type of the domain context. (Inherited from WebAuthenticationService.)
Public propertyIsBusyGets a value indicating whether an asynchronous operation is in progress. (Inherited from AuthenticationService.)
Public propertyIsLoadingUserGets a value indicating whether an asynchronous LoadUser operation is in progress. (Inherited from AuthenticationService.)
Public propertyIsLoggingInGets a value indicating whether an asynchronous Login operation is in progress. (Inherited from AuthenticationService.)
Public propertyIsLoggingOutGets a value indicating whether an asynchronous Logout operation is in progress. (Inherited from AuthenticationService.)
Public propertyIsSavingUserGets a value indicating whether an asynchronous SaveUser operation is in progress. (Inherited from AuthenticationService.)
Protected propertySupportsCancellationGets a value that indicates whether this service supports cancellation. (Inherited from WebAuthenticationService.)
Public propertyUserGets a principal representing the authenticated user. (Inherited from AuthenticationService.)
Top

  NameDescription
Protected methodBeginLoadUserBegins an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected methodBeginLoginBegins an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected methodBeginLogoutBegins an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected methodBeginSaveUserBegins an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Protected methodCancelLoadUserCancels an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected methodCancelLoginCancels an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected methodCancelLogoutCancels an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected methodCancelSaveUserCancels an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Protected methodCreateDefaultUserCreates a default user. (Inherited from WebAuthenticationService.)
Protected methodEndLoadUserEnds an asynchronous LoadUser operation. (Inherited from WebAuthenticationService.)
Protected methodEndLoginEnds an asynchronous Login operation. (Inherited from WebAuthenticationService.)
Protected methodEndLogoutEnds an asynchronous Logout operation. (Inherited from WebAuthenticationService.)
Protected methodEndSaveUserEnds an asynchronous SaveUser operation. (Inherited from WebAuthenticationService.)
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodInitializeInitializes this authentication service. (Inherited from WebAuthenticationService.)
Public methodLoadUser()Asynchronously loads the authenticated user from the server. (Inherited from AuthenticationService.)
Public methodLoadUser(Action<LoadUserOperation>, Object)Asynchronously loads the authenticated user from the server with specified callback method and user state. (Inherited from AuthenticationService.)
Public methodLogin(LoginParameters)Asynchronously authenticates and logs in to the server with the specified parameters. (Inherited from AuthenticationService.)
Public methodLogin(String, String)Asynchronously authenticates and logs in to the server with the specified user name and password. (Inherited from AuthenticationService.)
Public methodLogin(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 methodLogout(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 methodLogout(Action<LogoutOperation>, Object)Asynchronously logs out an authenticated user from the server with the specified callback method and user state. (Inherited from AuthenticationService.)
Protected methodMemberwiseClone (Inherited from Object.)
Protected methodOnPropertyChangedRaises a PropertyChanged event. (Inherited from AuthenticationService.)
Protected methodRaisePropertyChangedRaises a PropertyChanged event for the specified property. (Inherited from AuthenticationService.)
Public methodSaveUser(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 methodSaveUser(Action<SaveUserOperation>, Object)Asynchronously saves the authenticated user to the server with the specified callback method and user state. (Inherited from AuthenticationService.)
Public methodToString (Inherited from Object.)
Top

  NameDescription
Public eventLoggedInOccurs when a new user is successfully logged in. (Inherited from AuthenticationService.)
Public eventLoggedOutOccurs when a user is successfully logged out. (Inherited from AuthenticationService.)
Top

  NameDescription
Explicit interface implemetationPrivate eventINotifyPropertyChanged.PropertyChangedOccurs every time a property value changes. (Inherited from AuthenticationService.)
Top

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 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);
}


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:
© 2014 Microsoft