protected void Page_Load(object sender, EventArgs e) { } protected void btnRegister_Click(object sender, EventArgs e) { if (Page.IsValid) { try { //a connection for db where user info can be stored UserStore<IdentityUser> userStore = new UserStore<IdentityUser>(); //Set ConnectionString to BkObserverDBConnectionString userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager. ConnectionStrings["BkObserverDBConnectionString"].ConnectionString; UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore); //Create new user and try to store in db IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; user.Email = txtEmail.Text; user.PhoneNumber = txtPhone.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { //Create user object. //Database will be created / expanded automatically. IdentityResult result = manager.Create(user, txtPassword.Text); //Create new User Role IdentityUserRole userrole = new IdentityUserRole(); string roleId = "3"; //3 is Advertiser in AspNetRole table userrole.UserId = user.Id; userrole.RoleId = roleId; //this is where I want to save user role to aspNetUserRole table manager.AddUserToRole(userrole.UserId, userrole.RoleId);...
try { //a connection for db where user info can be stored UserStore<IdentityUser> userStore = new UserStore<IdentityUser>(); //Set ConnectionString to BkObserverDBConnectionString userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager. ConnectionStrings["BkObserverDBConnectionString"].ConnectionString; UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore); //Create new user and try to store in db IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; user.Email = txtEmail.Text; user.PhoneNumber = txtPhone.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { //Create user object. //Database will be created / expanded automatically. IdentityResult result = manager.Create(user, txtPassword.Text); //Create new User Role IdentityUserRole userrole = new IdentityUserRole(); string roleId = "3"; //3 is Advertiser in AspNetRole table userrole.UserId = user.Id; userrole.RoleId = roleId; //this is where I want to save user role to aspNetUserRole table manager.AddUserToRole(userrole.UserId, userrole.RoleId);...
//a connection for db where user info can be stored UserStore<IdentityUser> userStore = new UserStore<IdentityUser>(); //Set ConnectionString to BkObserverDBConnectionString userStore.Context.Database.Connection.ConnectionString = System.Configuration.ConfigurationManager. ConnectionStrings["BkObserverDBConnectionString"].ConnectionString; UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore); //Create new user and try to store in db IdentityUser user = new IdentityUser(); user.UserName = txtUserName.Text; user.Email = txtEmail.Text; user.PhoneNumber = txtPhone.Text; if (txtPassword.Text == txtConfirmPassword.Text) { try { //Create user object. //Database will be created / expanded automatically. IdentityResult result = manager.Create(user, txtPassword.Text); //Create new User Role IdentityUserRole userrole = new IdentityUserRole(); string roleId = "3"; //3 is Advertiser in AspNetRole table userrole.UserId = user.Id; userrole.RoleId = roleId; //this is where I want to save user role to aspNetUserRole table manager.AddUserToRole(userrole.UserId, userrole.RoleId);...
try { //Create user object. //Database will be created / expanded automatically. IdentityResult result = manager.Create(user, txtPassword.Text); //Create new User Role IdentityUserRole userrole = new IdentityUserRole(); string roleId = "3"; //3 is Advertiser in AspNetRole table userrole.UserId = user.Id; userrole.RoleId = roleId; //this is where I want to save user role to aspNetUserRole table manager.AddUserToRole(userrole.UserId, userrole.RoleId);...