public void FoodieLogin(object sender, EventArgs e) { bool isValidEmail = false; isValidEmail = Regex.IsMatch(txtEmailId.Text, @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$", RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)); if (!String.IsNullOrEmpty(txtEmailId.Text) && !String.IsNullOrEmpty(txtPassword.Text) && isValidEmail && txtPassword.Text.Length > 5) { UserSession userDetails = new UserSession(); userDetails = UserDetails.GetFoodieAccountDetails(txtEmailId.Text, txtPassword.Text); if (!String.IsNullOrEmpty(userDetails.FirstName) && !String.IsNullOrEmpty(userDetails.LastName) && !String.IsNullOrEmpty(userDetails.UserId)) { HttpContext.Current.Session["UserId"] = userDetails.UserId; HttpContext.Current.Session["FirstName"] = userDetails.FirstName; HttpContext.Current.Session["LastName"] = userDetails.LastName; HttpContext.Current.Session["Type"] = "1"; Response.Redirect("/"); } else { spnFoodieLoginStatus.InnerText = "Error while logging in.Please check your credentials"; } } }