Clase FormsAuthentication
Proporciona una implementación de servicios de autenticación que efectúa autenticación mediante formularios con una clase DomainContext que se genera a partir de un servicio de dominio que implementa la interfaz IAuthentication.
Espacio de nombres: System.ServiceModel.DomainServices.Client.ApplicationServices
Ensamblado: System.ServiceModel.DomainServices.Client.Web (en system.servicemodel.domainservices.client.web.dll)
Uso
'Uso
Dim instance As FormsAuthentication
Sintaxis
'Declaración
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
Notas
Para configurar la aplicación de forma que use autenticación mediante formularios, es preciso que establezca valores en el proyecto de servidor y en el de cliente. Se utiliza la clase FormsAuthentication cuando se establece el valor en el proyecto de cliente.
En el archivo Web.config del proyecto de servidor, establezca el modo de autenticación en “Forms”
, tal como se muestra en el ejemplo siguiente.
<system.web>
<authentication mode="Forms"></authentication>
</system.web>
En el constructor del objeto Application para la aplicación cliente, establezca la propiedad Authentication del objeto WebContext en FormsAuthentication, tal como se muestra en el ejemplo siguiente. El constructor se encuentra por lo general en un archivo denominado 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);
}
Jerarquía de herencia
System.Object
System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService
System.ServiceModel.DomainServices.Client.ApplicationServices.WebAuthenticationService
System.ServiceModel.DomainServices.Client.ApplicationServices.FormsAuthentication
Seguridad para subprocesos
Cualquier miembro estático público (Compartidos en Visual Basic) de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.
Plataformas
Plataformas de desarrollo
Microsoft Windows XP Home Edition, Windows XP Professional, Windows Server 2003 , Windows Server 2008 y Windows 2000
Plataformas de destino
Change History
Vea también
Referencia
Miembros FormsAuthentication
Espacio de nombres System.ServiceModel.DomainServices.Client.ApplicationServices