I am using this to add a newly created user, to role:
var db = new ApplicationDbContext();
ApplicationDbContext context = new ApplicationDbContext();
var userStore = new UserStore<ApplicationUser>(context);
var userManager = new UserManager<ApplicationUser>(userStore);
userManager.AddToRole(user.Id, model.UserRole);
In my solution username = email.
I have discovered, when the username/email contains a sign (+, - or anything like that), it will not add the user to a role. The error i get is "User name x is invalid, can only contain letters or digits.".
The user gets added succesfully, it is just the AddToRole, that fails.
But i cannot figure out why.
AllowOnlyAlphanumericUserNames is set to false, in IdentityConfig.cs
Any ideas?