I have a table of Roles in the DB and a table which holds which users belong to which roles.
I then want the ability in ASP.NET to see if a user belongs to a role using IsInRole(RoleName);
I understand I need to create a CustomPrincipal and implement the IPrincipal interface and for the IsInRole method, create the procedure I want to validate the parameter against a datasource.
Problem here is performance where it means I have to go to the DB everytime to see if the user (stored in session) belongs to that role.
Is there a way to cache the data for checking to see if the current user is in a role?
Maybe im missing something or a better way of doing this? I must stress that I want to use the User.IsInRole("...") method.
ahmedilyas
Member
414 Points
588 Posts
IsInRole Cache
Feb 07, 2012 10:11 PM|LINK
Hi.
I am creating my own "Roles".
I have a table of Roles in the DB and a table which holds which users belong to which roles.
I then want the ability in ASP.NET to see if a user belongs to a role using IsInRole(RoleName);
I understand I need to create a CustomPrincipal and implement the IPrincipal interface and for the IsInRole method, create the procedure I want to validate the parameter against a datasource.
Problem here is performance where it means I have to go to the DB everytime to see if the user (stored in session) belongs to that role.
Is there a way to cache the data for checking to see if the current user is in a role?
Maybe im missing something or a better way of doing this? I must stress that I want to use the User.IsInRole("...") method.