How to check what the current users role is

You can use Roles.GetRolesForUser() method to get all the rols user belong to . use it like this;

string[] rolesuserbelongto = Roles.GetRolesForUser();

you will have all roles in string array.

you can even pass a UserName as a parameter to get the roles for that particular User like this:

string[] rolesuserbelongto = Roles.GetRolesForUser("Shekhar_Pro");

The most general method is to get an IPrinciple and then call IsInRole() on it. How you get the Principle denpends on your runtime environment. This example works well for apps running under the user's account.

Example:

    static void PrintIsInAdministrators()
    {
        // There are many ways to get a principle... this is one.
        System.Security.Principal.IPrincipal principle = System.Threading.Thread.CurrentPrincipal;
        bool isInRole = principle.IsInRole("MyDomain\\MyRole");
        Console.WriteLine("I {0} an Admin", isInRole ? "am" : "am not");
    }

Roles.GetRolesForUser(); gave me the error The Role Manager feature has not been enabled.

If you are using ASP.NET Identity UserManager you can get it like this:

var userManager = Request.GetOwinContext().GetUserManager<ApplicationUserManager>();

var roles = userManager.GetRoles(User.Identity.GetUserId());

If you have changed key for user from Guid to Int for example use this code:

var roles = userManager.GetRoles(User.Identity.GetUserId<int>());