asp.net - Should my custom RoleProvider throw an exception in AddUsersToRoles? -
asp.net - Should my custom RoleProvider throw an exception in AddUsersToRoles? -
i'm implementing custom asp.net role provider, , i'm wondering whether adduserstoroles
method should throw providerexception
if user passed in in role passed in. default microsoft sql server role provider sqlroleprovider
exhibits behaviour, though official microsoft documentation doesn't recommend it:
exception details: system.configuration.provider.providerexception: user 'mytestuser' in role 'mytestrole'.
i think useful provider not throw exception in case move on when given user in given role; way calling code doesn't need worry duplicates. there existing role provider-using code relies on exception beingness thrown in case? if there is, should doing given microsoft don't seem recommend it?
if want implement method similar adduserstoroles
doesn't throw exception when user in role, can see 3 alternatives:
adduserstoroles
, have different behaviour default sqlroleprovider
. implement new ensureusersinroles
method in role provider class, , access calling code using ((myprovider)(roles.provider)).ensureusersinroles()
. just implement in totally separate class.
personally, i'd conform microsoft does. hard rule out possibility somewhere require exception thrown.
asp.net exception roleprovider
Comments
Post a Comment