RoleProvider question -- help please (.NET 2.0)

Discussion in 'ASP .Net' started by Burak Gunay, Mar 21, 2006.

  1. Burak Gunay

    Burak Gunay Guest

    Hello,

    I derived a custom provider from the provider class. I set

    cookieless="UseUri"

    in the web.config, because we don't want data stored on client
    machines.

    Now, as I understand it, the information from the Membership Provider
    gets serialized and saved on the url, but the same does not apply to
    the RoleProvider info.

    Everytime a page with <asp:loginview> is called, the Role Provider page
    gets called and the database gets queried, whereas the database does
    not need to be queried again for user info by the Membership Provider,
    since the info is saved on the url.

    I tried to save the roles() as a session variable in the Role Provider
    page but since that page is a vb class, it does not recognize the
    Session class.

    How can we save the roles() info so that we don't have to call the Role
    Provider each time to figure out the roles assigned to a user?

    Thanks,

    Burak
     
    Burak Gunay, Mar 21, 2006
    #1
    1. Advertising

  2. On 21 Mar 2006 06:05:10 -0800, Burak Gunay wrote:

    > How can we save the roles() info so that we don't have to call the Role
    > Provider each time to figure out the roles assigned to a user?


    By default, asp.net caches the roles for the current user, so it will call
    your providers GetRolesForUser() method once and only once for the session,
    after that it will return cached results.
     
    Erik Funkenbusch, Mar 21, 2006
    #2
    1. Advertising

  3. Burak Gunay

    Burak Gunay Guest

    Erik,

    Are you sure about that? I have the following setting in my web.config

    <membership defaultProvider="MyMembershipProvider">
    <providers>
    <clear/>
    <add name="MyMembershipProvider"
    type="MyMembershipProvider"></add>
    </providers>
    </membership>

    and it calls the GetRolesForUser() method every time a page with a
    loginview control comes up.

    When I set the cookies on as follows

    <roleManager defaultProvider="MyRoleProvider" enabled="true"
    cacheRolesInCookie="true"
    cookieName=".ASPXROLES"
    cookiePath="/"
    cookieTimeout="30"
    cookieRequireSSL="false"
    cookieSlidingExpiration="true"
    createPersistentCookie="false"
    cookieProtection="All" >

    then it calls GetRolesForUser() only once.

    Burak
     
    Burak Gunay, Mar 22, 2006
    #3
  4. On 22 Mar 2006 06:13:56 -0800, Burak Gunay wrote:

    > Erik,
    >
    > Are you sure about that? I have the following setting in my web.config


    ....

    > and it calls the GetRolesForUser() method every time a page with a
    > loginview control comes up.


    Correct. It has to call GetRolesForUser the first time (ie, when he logs
    in), but after that, whenever UserPrincipal.IsInRole is called, it uses the
    cached version.
     
    Erik Funkenbusch, Mar 22, 2006
    #4
  5. On Wed, 22 Mar 2006 13:52:59 -0600, Erik Funkenbusch wrote:

    > On 22 Mar 2006 06:13:56 -0800, Burak Gunay wrote:
    >
    >> Erik,
    >>
    >> Are you sure about that? I have the following setting in my web.config

    >
    > ...
    >
    >> and it calls the GetRolesForUser() method every time a page with a
    >> loginview control comes up.

    >
    > Correct. It has to call GetRolesForUser the first time (ie, when he logs
    > in), but after that, whenever UserPrincipal.IsInRole is called, it uses the
    > cached version.


    Sorry, I reread this and realized you were talking about something else. I
    haven't looked at the LoginView control yet, but it may be calling
    GetRolesForUser() directly rather than using IsInRole
     
    Erik Funkenbusch, Mar 22, 2006
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    646
    Big Brian
    Oct 14, 2003
  2. Burak Gunay

    Custom RoleProvider question -- saving roles

    Burak Gunay, Mar 21, 2006, in forum: ASP .Net Security
    Replies:
    0
    Views:
    129
    Burak Gunay
    Mar 21, 2006
  3. Burak Gunay

    Custom RoleProvider question -- saving roles

    Burak Gunay, Mar 21, 2006, in forum: ASP .Net Security
    Replies:
    8
    Views:
    345
    Dominick Baier [DevelopMentor]
    Mar 22, 2006
  4. Keith Patrick
    Replies:
    1
    Views:
    651
    Dominick Baier
    Aug 20, 2006
  5. Replies:
    0
    Views:
    147
Loading...

Share This Page