ASP.Net Roles and Membership check for Users in role for multiple roles

ASP.Net Roles and Membership check for Users in role for multiple roles:

I have users in membership and one user can have one or more than one roles assigned. I want to check for specific roles of a page for example:
Role1, Role2, Role3, Role4, Role5
Users who have access of Role2 and Role3 can access Page1.aspx and Also if user who have access of Role1 and Role2 also can access because Role2 is there available.

Membership check for Users in role:

I have implemented membership and have list of user's roles string array with the help of
string[] roles = Roles.GetRolesForUser(User.Identity.Name);
How can I check against multiple roles? May I need to do one by one check with using Roles.IsUserInRole function?
I have used; It returns 0 count because of Partner in capital. How can I do ignore case? And is below is right way to check array against array?
string[] userroles = { "Partner", "testsetsr" };

 string[] requiredroles = { "contractor", "customer", "sims", "nonclientau", "partner" };

        var countInRoles = userroles.Intersect(requiredroles).Count();

Comments

Popular posts from this blog