public static bool CreateUser(string username , string password, string recoveryEmail , string question1, string answer1, string question2, string answer2) { bool UserCreated = true; MembershipUser user = null; if (HttpContext.Current.Session["UserID"] == null) { if (Membership.GetUser(username) == null) { user = Membership.CreateUser(username, password, recoveryEmail); if (user != null) { Roles.AddUserToRole(username, "Members"); /*We need the following method to execute otherwise the * logged in user won't be Initialized correctly */ Common.InitializeUser(username, HttpContext.Current); ProfileCommon profile = ProfileCommon.GetProfile(); profile.SecurityQuestions.Question1 = question1; profile.SecurityQuestions.Answer1 = answer1; profile.SecurityQuestions.Question2 = question2; profile.SecurityQuestions.Answer2 = answer2; profile.Save(); HttpContext.Current.Session["UserID"] = user.ProviderUserKey; } else { UserCreated = false; } } else // The user has already been created but some information like below can be updated { ProfileCommon profile = ProfileCommon.GetProfile(); profile.SecurityQuestions.Question1 = question1; profile.SecurityQuestions.Answer1 = answer1; profile.SecurityQuestions.Question2 = question2; profile.SecurityQuestions.Answer2 = answer2; profile.Save(); HttpContext.Current.Session["UserID"] = Membership.GetUser(username).ProviderUserKey; } } return(UserCreated); }
protected void btnSearch_Click(object sender, EventArgs e) { if (txtKeyword.Text != "") { whereClause = "DD=" + Server.HtmlEncode(txtKeyword.Text); } if (txtLocation.Text != "") { whereClause += "&LL=" + Server.HtmlEncode(txtLocation.Text); } objDSJob.Select(); lwSearchResult.DataBind(); ProfileCommon profile = ProfileCommon.GetProfile(); profile.RecentSearch.Keywords = txtKeyword.Text; profile.Save(); }