Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="webLogin.aspx.cs" Inherits="capaPresentacion.webLogin" %>
  2.  
  3. <!DOCTYPE html>
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml">
  6. <head runat="server">
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  8. <title></title>
  9. <style type="text/css">
  10. .auto-style1 {
  11. margin-left: 371px;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <form id="form1" runat="server">
  17. <div>
  18.  
  19. <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">
  20. <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
  21. <LoginButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" />
  22. <TextBoxStyle Font-Size="0.8em" />
  23. <TitleTextStyle BackColor="#507CD1" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
  24. </asp:Login>
  25.  
  26. </div>
  27. </form>
  28. </body>
  29. </html>
  30.  
  31.  
  32. ------------------------------------------------------------------------------------
  33.  
  34.  
  35.  
  36. using System;
  37. using System.Collections.Generic;
  38. using System.Linq;
  39. using System.Web;
  40. using System.Web.UI;
  41. using System.Web.UI.WebControls;
  42. using capaLogicaNegocio;
  43. using System.IO;
  44. using System.Xml.Serialization;
  45. using System.Web.Security;
  46.  
  47. namespace capaPresentacion
  48. {
  49. public partial class webLogin : System.Web.UI.Page
  50. {
  51. CL_Usuario usuario = new CL_Usuario();
  52. protected void Page_Load(object sender, EventArgs e)
  53. {
  54.  
  55. }
  56.  
  57. protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
  58. {
  59. servicioAutenticacion.OperacionesClient servicio = new servicioAutenticacion.OperacionesClient();
  60.  
  61. XmlSerializer serializador = new XmlSerializer(typeof(CL_Usuario));
  62.  
  63. StringReader lector = new StringReader(servicio.validar(Login.UserName, Login.Password));
  64.  
  65. CL_Usuario usu = (CL_Usuario)serializador.Deserialize(lector);
  66.  
  67. if (usu != null)
  68. {
  69. Login.UserName = usu.Nombre + " " + usu.Apellido;
  70. e.Authenticated = true;
  71.  
  72. Session["Usuario Valido"] = usu;
  73.  
  74. //el redirect no funciona si no agrega la etiqueta <authorization> y <authentication> en el Web.Config
  75. FormsAuthentication.RedirectFromLoginPage(Login.UserName, false);
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement