protected void btnLogin_Click(object sender, EventArgs e) { IRepoUsuario repo = new RepoUsuario(); Usuario usr; try { usr = repo.Login(txtUser.Text, txtPass.Text); if (usr != null) { Session["user"] = usr.User; Session["role"] = usr.Role; Session["dicose"] = usr.Dicose.ToString(); lblError.Visible = false; } else { lblError.Visible = true; } } catch { lblError.Visible = true; throw; } finally { if (Session["user"].ToString().Length > 0) { Response.Redirect("home.aspx"); } } }