IsUserInRole too slow - ASP.NET
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
Your could implement a custom Role Provider[^] - I do - and then the responsibility is yours. Mine works by using a enum in the user info, so it is one access to the DB at most (normally none since the user profile is already downloaded).
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
-
While debugging my slow application, I found the culprit is
Roles.IsUserInRole
It take from 3 sec to 9 second to execute. I found the reason it through the entire user list and calls other function, but it shouldn't be that slow to what I understand. My question is can it be made faster?
Are you trying to determine if the current logged in user is in a role, i.e. for customising a page view? Have you tried using User.IsInRole against Roles.IsUserInRole? Don't know what you are doing, but the User. method should not need to iterate the entire user list (unless the inner working of the membership provides end up doing the same thing).
Dave Find Me On: Web|Facebook|Twitter|LinkedIn
Folding Stats: Team CodeProject
-
Are you trying to determine if the current logged in user is in a role, i.e. for customising a page view? Have you tried using User.IsInRole against Roles.IsUserInRole? Don't know what you are doing, but the User. method should not need to iterate the entire user list (unless the inner working of the membership provides end up doing the same thing).
Dave Find Me On: Web|Facebook|Twitter|LinkedIn
Folding Stats: Team CodeProject
-
I am checking if the user in in role, he is allowed access to the page. If he is not, he is shown the error message. I have not trie User.IsInRole, somewhere I read, it give different result.
-
From what you are saying, then the User.IsInRole is what you want, as the user is already logged into the system.
Dave Find Me On: Web|Facebook|Twitter|LinkedIn
Folding Stats: Team CodeProject
-
From what you are saying, then the User.IsInRole is what you want, as the user is already logged into the system.
Dave Find Me On: Web|Facebook|Twitter|LinkedIn
Folding Stats: Team CodeProject
-
Ok tried it. It did work but it also took 13 seconds to execute. Note that I have tracing enabled.
Ok, so have you tried to profile your code and the Database. Sounds like you have some severe latency, probably in the database on disk. a) How many users in the user list? b) How many roles in the roles list? c) What sort of database are you using? d) Is the application and the database running on the same PC? Or is it distributed? What sort of connection is between them? e) Is their anything else that is slow in the application? f) Are you overriding any of the base methods and trying to role your own? These are some of the question you should be asking yourself. Next thing to do would be create a fresh vanilla application, add a couple of users and and a couple of roles and then run the IsInRole and IsUserInRole and see what difference you get.
Dave Find Me On: Web|Facebook|Twitter|LinkedIn
Folding Stats: Team CodeProject
-
Ok, so have you tried to profile your code and the Database. Sounds like you have some severe latency, probably in the database on disk. a) How many users in the user list? b) How many roles in the roles list? c) What sort of database are you using? d) Is the application and the database running on the same PC? Or is it distributed? What sort of connection is between them? e) Is their anything else that is slow in the application? f) Are you overriding any of the base methods and trying to role your own? These are some of the question you should be asking yourself. Next thing to do would be create a fresh vanilla application, add a couple of users and and a couple of roles and then run the IsInRole and IsUserInRole and see what difference you get.
Dave Find Me On: Web|Facebook|Twitter|LinkedIn
Folding Stats: Team CodeProject
This is great advice. The fact is I have not worked a great deal with roles, profils etc and I just getting to know what providers are. 1. I have about 30 total users (max) 2. I have about 10 roles 3. SQL Server 2005 4. yes 5. No, when any page is access that has IsUserInRole, it is very slow 6. I am not overriding any function but thinking about it now. Something to note, this application was change from time to time so it also has old users which are about the same in numbers but obviously as upgraded the program, we created new users and the old ones are still in the database.