protected void btnLogin_Click(object sender, EventArgs e) { if (Page.IsValid) { IUsr Usr = new Usr(APP_username.Value.ToLower().Trim(), APPpassword.Value); if (Usr.usr != null & Usr.IsAuth()) { if (Usr.IsActive()) { 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.PaisAppId.ToString(), FormsAuthentication.FormsCookiePath); String crypTicket = FormsAuthentication.Encrypt(authTicket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, crypTicket); //authCookie.Expires = DateTime.Now.AddMinutes(FormsAuthentication.Timeout.TotalMinutes); Response.Cookies.Add(authCookie); Session["Usr"] = Usr; // String dp = Usr.DefaultPage(); Response.Redirect("~" + "/Account/Home.aspx"); } else { lblErrorMsg.Text = "Usuario Inactivo"; lblErrorMsg.Visible = true; } } else { lblErrorMsg.Text = "Usuario o Contraseña Incorrecto"; lblErrorMsg.Visible = true; } } }
protected void ddlPaisCtx_SelectedIndexChanged(object sender, EventArgs e) { if (Session["Usr"] != null) { Usr a = new Usr(); var usr = a.getUserData((((Usr)Session["Usr"]).usr.CemexID)); if (usr != null) { ((Usr)Session["Usr"]).usr = usr; UsrCache.AddPagesToCache(((Usr)Session["Usr"]).usr.CemexID, ((Usr)Session["Usr"]).GetDataCache(), HttpContext.Current); Response.Redirect("~/Home.aspx"); } } else { Response.Redirect("~/Account/CerrarSession.aspx"); } }