Umbraco Role Based Protection - Getting A Content Page's Membership Roles & Getting Membership Roles of a User
If you have set up Public Access roles for a content page using the Umbraco CMS and you need to reach the roles of this content page in the code behind, then this is how you can do it;
Happy coding.
var roles = umbraco.cms.businesslogic.web.Access.GetAccessingMembershipRoles(content.Id,content.Path);
If you need to get all roles, then this is how you can get it;var allRoles = ApplicationContext.Current.Services.MemberService.GetAllRoles();
In addition to this, we can get the member roles as shown below;var memberRoles = System.Web.Security.Roles.GetRolesForUser(member.Username).ToList();
Happy coding.
Comments
Post a Comment