views:

60

answers:

3

hey everyone,

I've enabled Roles in my ASP.NET web application, but I'm slightly confused as to where they are being stored. In my old project, each Role would appear in the ASP.NET Roles table, and I could see them. However, in my new project, I can't see any Roles in the database table. The strange thing is, I can still use them (and the default Roles/Membership API) and everything works fine. Any ideas why they are not appearing the database table itself, and where they are actually being stored?

My web.config file has this:

<roleManager enabled="true" />

Using the ASP.NET configuration tool, my default Role provider is AspNetSqlRoleProvider.

Thanks Update I added this explicitly in my web.confg

 <roleManager enabled="true" >

      <providers>
        <clear/>
        <add connectionStringName="myDBConnectionString" name="AspNetSqlRoleProvider"/>
      </providers>
    </roleManager>
A: 

In your asp.net membership database are two tables: aspnet_Roles contains the roles and aspnet_UsersInRoles contains the association of users with roles.

Residuum
That's what I expected, but there's nothing in there.
Skoder
Do you executed the aspnet_reqsql utility and selected the roles tables for generation?
Residuum
A: 

it will build it’s OWN database in the App_Data folder and create the required tables there

Amgad Fahmi
There's nothing in my App_Data folder. I've updated my tags to show I'm using SQL Server 2005 (forgot to put that in)
Skoder
run this aspnet_regsql untility you will find it created a database called aspnetdb
Amgad Fahmi
Hi, I already have the asp membership tables. The users I create appear in the tables and I can access them. I can also access the roles, but they're not showing in the tables.
Skoder
u said you already have the membership tables and then u said they're not showing in the tables , can't get it ?
Amgad Fahmi
+1  A: 

Hello,

By default, it does use the local database unless the role provider points to a database using a different database connection.

If you setup the tables in your own custom database and not the ASPNETDB.mdf file, then you will have to setup a custom provider definition pointing to the SQLroleprovider, and provide a custom connection string reference to where the database is.

HTH.

Brian
Ah, that's sorted it. I added provider details in the roleManager section. Strange it didn't appear automatically as in my previous project, I hadn't explicitly added anything, yet it was the default.Oh well, thanks for the help!
Skoder