Classe FormsAuthentication

Fornisce un'implementazione del servizio di autenticazione che esegue l'autenticazione basata su form utilizzando un oggetto DomainContext generato da un servizio del dominio che implementa l'interfaccia IAuthentication.

Spazio dei nomi: System.ServiceModel.DomainServices.Client.ApplicationServices
Assembly: System.ServiceModel.DomainServices.Client.Web (in system.servicemodel.domainservices.client.web.dll)

Utilizzo

'Utilizzo
Dim instance As FormsAuthentication

Sintassi

'Dichiarazione
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

Osservazioni

Per configurare l'applicazione in modo da utilizzare l'autenticazione basata su form, è necessario impostare i valori sia nel progetto server che in quello client. È possibile utilizzare la classe FormsAuthentication per impostare il valore nel progetto client.

Nel file Web.config del progetto server impostare la modalità di autenticazione su “Forms”, come illustrato nell'esempio seguente.

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

Nel costruttore dell'oggetto Application per l'applicazione client impostare la proprietà Authentication dell'oggetto WebContext su FormsAuthentication, come illustrato nell'esempio seguente. Il costruttore si trova in genere in un file denominato App.xaml.cs o 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);
}

Gerarchia di ereditarietà

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

Sicurezza dei thread

Tutti i membri statici pubblici (Shared in Visual Basic) di questo tipo sono thread-safe. Non è invece garantita la sicurezza dei membri dell'istanza.

Piattaforme

Piattaforme di sviluppo

Windows XP Home Edition, Windows XP Professional, Windows Server 2003 , Windows Server 2008 e Windows 2000

Piattaforme di destinazione

Change History

Vedere anche

Riferimento

Membri FormsAuthentication
Spazio dei nomi System.ServiceModel.DomainServices.Client.ApplicationServices