I have this codes which work when adding a new account by using an admin account:
[Authorize(Roles = "Owner")] [HttpPost] [ValidateAntiForgeryToken] public ActionResult Create(UserProfile userprofile) { if (ModelState.IsValid) { db.UserProfiles.Add(userprofile); db.SaveChanges(); return RedirectToAction("Index"); } return View(userprofile); } but when I add this line of code
Roles.AddUserToRole(userprofile.UserId.ToString(), "4"); I get an error of:
No user found was found that has the name "11".
What should I do? Thanks in advance!