Membership problem - Roles Not working !

Discussion in 'ASP.NET 2.0' started by Arxaios, Apr 8, 2007.

  1. I am having a problem with asp.net's membership.
    When I run the site in my local machine it works great.
    Both roles and users deny or allow access to specific folders with no problems.
    If a role is denied in a certain folder the user will not be able to see any page in the folder.
    If a role is allowed the user can see all pages in the folder.

    But...
    when I upload the site the roles stop working!
    I cannot see any page in a folder even if the role I have is allowed.
    The only way to see a page is :
    a)to delete the web.config file (so everyone can see the pages of course)
    b)to explicitly allow a username to see the pages (which is very difficult to maintain)

    Here is an example.
    If I login with a 'BackOffice' role I can 't see any page in the folder if i use the folloing web.config file :


    <configuration xmlns='http://schemas.microsoft.com/.NetConfiguration/v2.0'>
    <system.web>
    <authorization>
    <allow roles='BackOffice' />
    <deny users='*' />
    </authorization>
    </system.web>
    </configuration>

    Did I do something wrong?
    Why roles work when I runh the same site locally?

    Any help will be much appreciated.
     
  2. Make sure your database on our server is consistent with that of your development environment.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET

    Post Edited (vvsharma) : 4/9/2007 7:03:09 PM GMT
     
  3. Vikram thanks for your answer.

    The problem is that when I run the site in my development environment I do not use a local connection string or a local database.
    I connect directly to the database hosted at DISCOUNTASP.NET.

    Is there something else I should know?
    Is there any configuration is my site 's Control Panel that overrides the settings in my web.config file?

    Thanks for your help.
     
  4. It seems that you dont have your role manager enabled in the web.config?
    i.e
    <system.web>
    <roleManager enabled='true' />
    <authorization>
    <allow roles='BackOffice' />
    <deny users='*' />
    </authorization>
    </system.web>
    ...

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. I have these lines in my web.config which is located in my root folder :

    <roleManager enabled='true' defaultProvider='CustomizedRoleProvider'>
    <providers>
    <add connectionStringName='SQL2005_264170_trustConnectionString'
    name='CustomizedRoleProvider' type='System.Web.Security.SqlRoleProvider' />
    </providers>
    </roleManager>

    I think it should be right.
    Remember it works fine (both roles and users) when I run the site from my local computer).

    Do I need to enable roles somehow in every seperate folder so that it works?


    Thanks again for your reply.
     
  6. Are you missing theapplicationName property in the membership and roleManager providers? Can you post a more complete root web.config.




    Aristotle

    DiscountASP.NET
    www.DiscountASP.NET
     
  7. Dear Aristotle,

    you were right,
    I was missing the application name in the roles section of the web.config file and that 's why it was not working.

    Thank you very much for your help.
     

Share This Page