Problem with GetAllRoles

  • Thread starter Thread starter Fendi Baba
  • Start date Start date
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
 
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
 
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
 
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
 
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.
 
Back
Top