Search code examples
asp.net-mvc-3iisasp.net-roles

ASP.NET MVC 3: manage users and roles inside the internet application


When I now want to manage (create/delete/edit) Users and Roles for my MVC 3 internet application, I need to go to inetmgr on the server and change the .NET Roles / .NET Users there.

Is it possible to manage these users and roles from within the MVC 3 internet application itself (without having to go to the inetmgr on the server itself)?

Which changes should be done (to do AccountController I guess)?

Thanks in advance


Solution

  • Whats wrong with:

    Roles.AddUserToRole(User.Username, "Create");
    

    and:

    Roles.RemoveUserFromRole(User.Username, "Create");
    

    Or if you are talking about managing roles themselves:

    Roles.CreateRole("View");
    

    Using these methods you could then create action methods and views to allow role management from within your application.