How to get Security.User.RoleNames as a string

How tcan I get Security.User.RoleNames as a string? I tried Security.User.RoleNames is IEnumerable<string> ? string.Join(", ", (IEnumerable<string>)Security.User.RoleNames).ToString() : Security.User.RoleNames.DefaultIfEmpty("None").ToString()

But I get System.ArgumentNullException: Value cannot be null. (Parameter 'source')

Hi @simon,

Indeed the RoleNames property isn't automatically populated and will be null by default. Check the SecurityService.cs file that Radzen has generated to see how RoleNames is populated:

user.RoleNames = await userManager.GetRolesAsync(user);

Thanks @korchev.
In blazor how would you recommend implementing a solution that will create the user roles list as a comma seperated string available for every page to use as a datasource filter?

Using string.Join.

Thanks, I have implemented a solution to load rolenames which is executed in the main page . I use a string join in my query filters which works well.
What I was really asking is where is the best place to load rolenames, i.e. execute "await Security.GetUserById(Security.User.Id)"