protected void btnLogin_Click(object sender, EventArgs e) { if (Page.IsValid) { IUsr Usr = new Usr(txtUsuario.Text.ToLower(), txtPass.Text, Int32.Parse(ddlPa.SelectedValue)); if (Usr.usr != null & Usr.IsAuth()) { if (Usr.IsActive()) { if (Usr.usr.Rol != null) { UsrCache.AddPagesToCache(Usr.usr.CemexId, Usr.GetDataCache(), HttpContext.Current); var authTicket = new FormsAuthenticationTicket(2, Usr.usr.CemexId, DateTime.Now, DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes), false, Usr.usr.Pais.IdPais.ToString(), FormsAuthentication.FormsCookiePath); String crypTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, crypTicket); //authCookie.Expires = DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes); Response.Cookies.Add(authCookie); Session["Usr"] = Usr; Response.Redirect("~" + Usr.DefaultPage()); } else { lblError.Text = "El usuario no tiene asignado un Rol valido"; lblError.Visible = true; } } else { lblError.Text = "Usuario Inactivo"; lblError.Visible = true; } } else { lblError.Text = "Usuario o Contraseña Incorrecto"; lblError.Visible = true; } } }