protected void Page_Load(object sender, EventArgs e) { HttpCookie uLoginIP = new HttpCookie("uLoginIP"); try { var host = Dns.GetHostEntry(Dns.GetHostName()); string IPAddress = (from ip in host.AddressList where ip.AddressFamily == AddressFamily.InterNetwork select ip.ToString()).FirstOrDefault(); uLoginIP["IPAddress"] = IPAddress; Response.Cookies.Add(uLoginIP); txtUserID.Focus(); if (!String.IsNullOrEmpty(Request.QueryString["Logout"]) && Request.QueryString["Logout"].ToString() == "True") { HttpCookie veCook = Request.Cookies["uLoginInfo"]; if (veCook != null) { veCook.Expires = DateTime.Now.AddHours(-2); Response.Cookies.Add(veCook); Response.Redirect("Default.aspx", false); } } HttpCookie uLogincook = Request.Cookies["uLoginInfo"]; if (uLogincook != null) { Response.Redirect("Default.aspx", false); } } catch (Exception ex) { Response.Write("<script LANGUAGE='JavaScript' >alert('Please contact administrator for assistant.')</script>"); al.WriteErrorLog(ex.Message, "Login FormLoad", ""); } txtUserID.Focus(); }