protected void btnLogin_Click(object sender, EventArgs e) { string userName = txtUsername.Text.Trim().ToUpper(); string passWord = txtPassword.Text.Trim(); UserServices userService = new UserServices(); string returnString = userService.ValidateUser(userName, passWord); if (IdProConstants.SUCCESS.Equals(returnString)) { User user = new User(); user = userService.getUserbyUserName(userName); EmployeeServices employeeService = new EmployeeServices(); Employee employee = new Employee(); employee = employeeService.getEmployeeByUserName(userName); if (user == null || employee == null) { returnString = IdProConstants.ADMIN; } //else if (UserStatusesConstants.INACTIVEEMPLOYEE.Equals(employee.getEmployeeStatus())) //{ // returnString = TransactionConfirmMessages.INACTIVEUSER; //} else { string role = user.getRole().Trim(); Session["role"] = role; Session["username"] = user.getUserName().Trim(); Session["name"] = employee.getFirstName(); FormsAuthenticationTicket tkt = default(FormsAuthenticationTicket); string cookiestr = null; System.Web.HttpCookie ck = default(System.Web.HttpCookie); tkt = new FormsAuthenticationTicket(1, txtUsername.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, role); cookiestr = FormsAuthentication.Encrypt(tkt); ck = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, cookiestr); ck.Path = FormsAuthentication.FormsCookiePath; Response.Cookies.Add(ck); string strRedirect = null; strRedirect = Request["ReturnURL"]; if (!string.IsNullOrEmpty(strRedirect) & strRedirect != "/") { Response.Redirect(strRedirect, true); } else { strRedirect = "ManageEmployee.aspx"; Response.Redirect(strRedirect, true); } } } lblMsg.Text = returnString; }