Does asp.net RoleManager really cache roles for the user in the cookie, if configured?

In my web.config, I have the role manager installed:

<roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPROLES" 
cookieTimeout="30" cookiePath="/" cookieRequireSSL="false" 
cookieSlidingExpiration="true" cookieProtection="All">

however, in our custom RoleProvider, it seems that the GetRolesForUser method is always called, and not as I expected, the RoleManager serving the roles from its cookie.

We use something like getting roles for the user:

string[] myroles = Role.GetRolesForUser("myuser");

Is there something that I am missing in the configuration or in using RoleManager

+3
source share
2 answers

You are missing out defaultProvider="yourRoleProviderName"on your web.config.

? cookie .

Role.GetRolesForUser("myuser");

, cookie .ASPROLES IsInRole GetRoles.

+4

, cacheRolesInCookie true.

+1

Source: https://habr.com/ru/post/1707887/


All Articles