protected void Page_Load(object sender, EventArgs e) { try { Context.Request.Browser.Adapters.Clear(); this.lblUsuario.Text = this.Session["Usuario"].ToString().ToLower(); if (!Page.IsPostBack) { LogeoLN llenarMenu = new LogeoLN(); llenarMenu.LlenarMenu(this.Menu1, this.Session["Usuario"].ToString().ToLower()); } if (Request.Url.Segments[Request.Url.Segments.Length - 1].ToString() != "Inicio.aspx") { LogeoLN BloquearMenu = new LogeoLN(); if (BloquearMenu.BloquearAcceso(this.Session["usuar"].ToString().ToLower(), Request.Url.Segments[Request.Url.Segments.Length - 1].ToString()) == 0) { Response.Redirect("~/Inicio.aspx"); } } } catch (Exception ex) { Response.Redirect("~/Login.aspx"); Console.WriteLine(ex.Message + " error"); //throw; } }
protected void btniniciar_Click(object sender, EventArgs e) { Regex val = new Regex("^[a-zA-Z0-9ñÑáéíóúÁÉÍÓÚ]+$"); if (val.IsMatch(this.TextUsuario.Text) && val.IsMatch(this.TextContraseña.Text)) { try { //VARIABLES DE SESIÓN this.Session["usuar"] = this.TextUsuario.Text; this.Session["Usuario"] = this.TextUsuario.Text; mstLogeo = new LogeoLN(); if (mstLogeo.Logearse(this.TextUsuario.Text, this.TextContraseña.Text) > 0) { FormsAuthentication.RedirectFromLoginPage(this.TextUsuario.Text, false); if (VerificaUsuarioRRHH(this.TextUsuario.Text)) { Response.Redirect("~/RH/Empleado/EditarFicha.aspx?id=" + this.TextUsuario.Text); } else { Response.Redirect("~/Inicio.aspx"); // Response.Redirect("~/RH/Vacaciones/Crear.aspx"); } } else { this.resultado.Text = "Usuario no autorizado..."; } } catch (Exception ex) { Console.WriteLine(ex.Message + "Error en inicio de sesión"); if (ex.Message != "Thread was being aborted.") { Response.Redirect("~/Error.aspx?No=" + ex.Message); } throw; } } else { this.resultado.Text = "Usuario no autorizado..."; this.TextUsuario.Text = ""; this.TextContraseña.Text = ""; this.TextUsuario.Focus(); } }//termina evento