public void MaintainCookies(string _username, string _password) { bool blValidUser = false; string _strUserType = string.Empty; string strLoggedHistoryId; try { objML_Login.UserName = _username; objML_Login.Password = objCommonClass.GetEncrptPassword(_password); DataTable dt = objBL_Login.BL_ExamLoginUser(objML_Login); if (dt != null) { if (dt.Rows.Count > 0) { txtEmail.Text = dt.Rows[0]["First_Name"].ToString(); Session["UserName"] = txtEmail.Text; Session["ExamName"] = dt.Rows[0]["ExamName"].ToString(); #region Maintain Login History try { //string strIP = GetIPAddress(); //string strMachine = GetMachineName(); //string Mac_Address = GetMACAddress(); // Remote IP string ipaddress; //string mac_address = GetMACAddress().ToString(); ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"]; if (ipaddress == "" || ipaddress == null) { ipaddress = Request.ServerVariables["REMOTE_ADDR"]; } // End objML_Login.ID = _username; objML_Login.IPAddress = ipaddress.ToString(); objML_Login.LoginDate = Convert.ToDateTime(System.DateTime.Now); objML_Login.MachineName = string.Empty; objML_Login.MacAddress = lblMac.Text != "" ? lblMac.Text : null; objML_Login.UserCode = Session["UserName"].ToString(); int x = objBL_Login.BL_InsIPAddressHistory(objML_Login); if (x == 1) { } int y = objBL_Login.BL_InsertHistory(objML_Login); if (y == 1) { } } catch { } #endregion Maintain Login History //Response.Redirect("Exam/FBNPCTearms.aspx"); Response.RedirectToRoute("FBNPCTearms", true); } else { txtEmail.Text = ""; ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('Email and Password Incorrect !');", true); } } } catch (Exception e) { ScriptManager.RegisterStartupScript(this, this.GetType(), "message", "alert('" + e.Message.ToString() + "');", true); } }