public JsonResult CreateMemberRegister(tblUserInformation objUser) { Dictionary<string, object> res = new Dictionary<string, object>(); try { using (var db = new TestEntity()) { Membership.ApplicationName = "/"; Membership.CreateUser(objUser.Phone.ToString(), objUser.Phone.ToString()); MembershipUser user = Membership.GetUser(objUser.Phone.ToString()); Roles.ApplicationName = "/"; if (!Roles.RoleExists("Customer")) { Roles.CreateRole("Customer"); Roles.AddUserToRole(objUser.Phone.ToString(), "Customer"); } else { Roles.AddUserToRole(objUser.Phone.ToString(), "Customer"); } tblUserInformation objmember = new tblUserInformation(); objmember.idUser = new Guid(user.ProviderUserKey.ToString()); objmember.FirstName = objUser.FirstName; objmember.LastName = objUser.LastName; objmember.Phone = objUser.Phone.ToString(); objmember.DOB = objUser.DOB; objmember.IsActive = true; objmember.IsCompleted = true; objmember.IsNotify = false; objmember.CreatedBy = User.Identity.Name; objmember.CreatedDatetime = DateTime.Now; db.tblUserInformations.Add(objmember); db.SaveChanges(); FormsAuthentication.SetAuthCookie(objUser.Phone.ToString(), false); Session["Username"] = null; Session["LanguageId"] = null; if (Session["Username"] == null) { Session["Username"] = objUser.FirstName + " " + objUser.LastName; } res["success"] = 1; } } catch (Exception ex) { res["error"] = 2; res["message"] = ex.Message.ToString(); } return Json(res, JsonRequestBehavior.AllowGet); }