Problem with GetAllRoles

F

Fendi Baba

i used the example in the MSDN to getroles and assign users to it on
my local development plat form and it worked flawlessly, When I move
the same code production, the rolesListbox does not get poplated. What
differences in the two environment can cuase this? What can I do to
overwrite this GetAllroles routine so that I can be assured I can get
the roles in the current application?

Here is the code, any insight will be much appreciated.



Dim rolesArray() As String
Dim users As MembershipUserCollection
Dim usersInRole() As String

Public Sub Page_Load()

Msg.Text = ""

If Not IsPostBack Then
' Bind roles to ListBox.
rolesArray = Roles.GetAllRoles()
RolesListBox.DataSource = rolesArray
RolesListBox.DataBind()

' Bind users to ListBox.

users = Membership.GetAllUsers()
UsersListBox.DataSource = users
UsersListBox.DataBind()
End If

If Not RolesListBox.SelectedItem Is Nothing Then
' Show users in role. Bind user list to GridView.

usersInRole =
Roles.GetUsersInRole(RolesListBox.SelectedItem.Value)
UsersInRoleGrid.DataSource = usersInRole
UsersInRoleGrid.DataBind()
End If

End Sub
 
G

Guest

i used the example in the MSDN to getroles and assign users to it on
my local development plat form and it worked flawlessly, When I move
the same code production, the rolesListbox does not get poplated. What
differences in the two environment can cuase this? What can I do to
overwrite this GetAllroles routine so that I can be assured I can get
the roles in the current application?

Here is the code, any insight will be much appreciated.

Dim rolesArray() As String
Dim users As MembershipUserCollection
Dim usersInRole() As String

Public Sub Page_Load()

Msg.Text = ""

If Not IsPostBack Then
' Bind roles to ListBox.
rolesArray = Roles.GetAllRoles()
RolesListBox.DataSource = rolesArray
RolesListBox.DataBind()

' Bind users to ListBox.

users = Membership.GetAllUsers()
UsersListBox.DataSource = users
UsersListBox.DataBind()
End If

If Not RolesListBox.SelectedItem Is Nothing Then
' Show users in role. Bind user list to GridView.

usersInRole =
Roles.GetUsersInRole(RolesListBox.SelectedItem.Value)
UsersInRoleGrid.DataSource = usersInRole
UsersInRoleGrid.DataBind()
End If

End Sub

Check your web.config and a roles provider
http://msdn2.microsoft.com/en-us/library/system.web.security.roles.aspx
 
F

Fendi Baba

Check your web.config and a roles providerhttp://msdn2.microsoft.com/en-us/library/system.web.security.roles.aspx- Hide quoted text -

- Show quoted text -

Alexey

Both my development and production web.config is the same. Both had
the line

<roleManager enabled="true" />

I did a quick test and added the custom role provider section in the
web.config in my development server and the rolelistbox which worked
fails to get any roles.

Any ideas what else could be the cause
 
G

Guest

Alexey

Both my development and production web.config is the same. Both had
the line

<roleManager enabled="true" />

I did a quick test and added the custom role provider section in the
web.config in my development server and the rolelistbox which worked
fails to get any roles.

Any ideas what else could be the cause- Hide quoted text -

- Show quoted text -

Have you populated the table aspnet_Roles on the remote server?

Have you specified an applicationName for all of your providers
property?

For example

<providers>
<add connectionStringName="..."
name="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
applicationName="/"
/>
</providers>

Hope it helps
 
F

Fendi Baba

Have you populated the table aspnet_Roles on the remote server?

Have you specified an applicationName for all of your providers
property?

For example

<providers>
<add connectionStringName="..."
name="SqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
applicationName="/"
/>
</providers>

Hope it helps- Hide quoted text -

- Show quoted text -

Yes, the roles are all populated int he remote server and it's already
in production. Currently users have been assign to the roles though
the administrative interface provided through VIsual Studio.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top