Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="webLogin.aspx.cs" Inherits="capaPresentacion.webLogin" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title></title>
- <style type="text/css">
- .auto-style1 {
- margin-left: 371px;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <asp:Login ID="Login" runat="server" OnAuthenticate="Login_Authenticate" BackColor="#EFF3FB" BorderColor="#B5C7DE" BorderPadding="4" BorderStyle="Solid" BorderWidth="1px" CssClass="auto-style1" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#333333">
- <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
- <LoginButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" />
- <TextBoxStyle Font-Size="0.8em" />
- <TitleTextStyle BackColor="#507CD1" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
- </asp:Login>
- </div>
- </form>
- </body>
- </html>
- ------------------------------------------------------------------------------------
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using capaLogicaNegocio;
- using System.IO;
- using System.Xml.Serialization;
- using System.Web.Security;
- namespace capaPresentacion
- {
- public partial class webLogin : System.Web.UI.Page
- {
- CL_Usuario usuario = new CL_Usuario();
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
- {
- servicioAutenticacion.OperacionesClient servicio = new servicioAutenticacion.OperacionesClient();
- XmlSerializer serializador = new XmlSerializer(typeof(CL_Usuario));
- StringReader lector = new StringReader(servicio.validar(Login.UserName, Login.Password));
- CL_Usuario usu = (CL_Usuario)serializador.Deserialize(lector);
- if (usu != null)
- {
- Login.UserName = usu.Nombre + " " + usu.Apellido;
- e.Authenticated = true;
- Session["Usuario Valido"] = usu;
- //el redirect no funciona si no agrega la etiqueta <authorization> y <authentication> en el Web.Config
- FormsAuthentication.RedirectFromLoginPage(Login.UserName, false);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement