Override the User.IsInRole and [Authorize(Roles = “Admin”)] for MVC4 application
问题 I have created a custom role provider for my MVC4 application where I have been successfully able to override CreateRole, GetAllRoles and RoleExists methods and link them to my existing database as follows: namespace Project.Providers { public class MyProvider : System.Web.Security.SqlRoleProvider { private MyContext dbcontext = new MyContext(System.Configuration.ConfigurationManager.ConnectionStrings["MyContext"].ConnectionString); private Repository<MyUser> userRepository; private