Share via


Classe FormsAuthentication

Fournit une implémentation de service d'authentification qui exécute l'authentification par formulaire à l'aide de DomainContext généré à partir d'un service de domaine qui implémente l'interface IAuthentication.

Espace de noms: System.ServiceModel.DomainServices.Client.ApplicationServices
Assembly : System.ServiceModel.DomainServices.Client.Web (dans system.servicemodel.domainservices.client.web.dll)

Utilisation

'Utilisation
Dim instance As FormsAuthentication

Syntaxe

'Déclaration
Public Class FormsAuthentication
    Inherits WebAuthenticationService
public class FormsAuthentication : WebAuthenticationService
public ref class FormsAuthentication : public WebAuthenticationService
public class FormsAuthentication extends WebAuthenticationService
public class FormsAuthentication extends WebAuthenticationService

Notes

Pour configurer votre application de manière à utiliser l'authentification par formulaire, vous devez définir des valeurs à la fois dans le projet serveur et dans le projet client. Vous utilisez la classe FormsAuthentication lors de la définition de la valeur dans le projet client.

Dans le fichier Web.config du projet serveur, définissez le mode d'authentification sur “Forms”, comme indiqué dans l'exemple suivant.

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

Dans le constructeur de l'objet Application de l'application cliente, définissez la propriété Authentication de l'objet WebContext sur FormsAuthentication, comme indiqué dans l'exemple suivant. Le constructeur se trouve généralement dans un fichier nommé App.xaml.cs ou 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);
}

Hiérarchie d'héritage

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

Sécurité des threads

Tous les membres publics statiques (Partagés dans Visual Basic) de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Plateformes

Plateformes de développement

Windows XP Édition familiale, Windows XP Professionnel, Windows Server 2003 , Windows Server 2008 et Windows 2000

Plateformes cibles

Change History

Voir aussi

Référence

Membres FormsAuthentication
Espace de noms System.ServiceModel.DomainServices.Client.ApplicationServices