0

I'm using ASP.NET's role provider, and everything is working swell. On my role administration screen, however, I'd like to show not just the names of existing roles, but their descriptions as well. The field exists in SQL table generated by the aspnet_regsql.exe utility, but there doesn't appear to be anything in the System.Web.Security namespace that references the field.

Currently, Roles.GetAllRoles() returns a string array containing the role names. I'd like to be able to return a List of ListItem, for example (to keep things simple). Or when creating a new role, I'd like to be able to set the description to something, rather than it to default to null.

I know I could just write a stored procedure to return the results I want and use a completely separate method. But I'd prefer if I could just derive something from the base and extend it to suit my needs. Is that possible?

Karl
  • 189
  • 2
  • 3
  • 16
  • I don't think the role provider framework is extensible in this way, and you'll have to just directly query to get the extension. – mason Dec 22 '16 at 18:10
  • Mostly no, with a side order of "let's not bother". Yes, you could certainly derive from `SqlRoleProvider` and extend it. But you can't override any existing method because you can't change the signatures, and you want to. And you can implement `ExtendedSqlRoleProvider.GetDescriptiveRoles()`, but there's no way to call that from the static `Roles` class. So now you're also looking at implementing `RolesExtended` that can wrap around providers to check for your extensions... you're basically down to writing your own framework, and all to get at a description. – Jeroen Mostert Dec 22 '16 at 20:36

0 Answers0