MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Role Management (Closed) (Mono Support )

Viewed 11931 time(s), 5 post(s) 9/13/2011 10:00:54 AMby manvir.kaur
manvir-kaur

manvir.kaur

9/13/2011 10:00:54 AM
I have only 3 roles in my application of admin, user and vendor. In my registration page, user can register as a user or vendor by selecting role from a dropdown.I have deleted all the existing roles from aspnet_Roles and given these 3 roles there. Now, on the registration page, i'm trying to assign the selected role to user using this code :

Roles.AddUserToRole(this.UserName, ddlUserType.SelectedItem.Text);

Here ddlUserType.SelectedItem.Text contains the text, which is there in RoleName field from aspnet_Roles table

This code is called after Account has been created.

However, its giving me an error of the role '' was not found

Can you pls tell me, where is the system looking for role, as it is there in db?Is it looking for the role in web.config file?

Also, i can see some roles in Web.config file as follows:

<add key="AdministratorRoles" value="Administrators;" />
<add key="NewsPublisherRoleName" value="Publishers" />
<add key="CalendarAdministratorRoles" value="Administrators,Publishers" />
<add key="AdManagerRoles" value="AdManager,Administrators" />
<add key="BlogAdministratorRoles" value="Administrators,Publishers" />

And one default user role as follows:

<add key="DefaultUserRoles" value="Users" />

What do i need to do with these roles in web.config file as i do not need them. Also i do not need any default role. In my application, user need to select the role from drop down list at the time of registration.
Shall i remove these roles from web.config file?
This content has not been rated yet. 
3046 Reputation 388 Total posts
khorvat

khorvat

9/13/2011 10:10:48 AM
Hi,

as I can see everything you are doing should be ok, except maybe one thing and it is related to the DropDown binding and the selected items. When you check the ddlUserType.SelectedItem.Text does it have a value ? Can you provide us with the code-behind source so we can take a look at the whole user control ?

Roles that you have mentioned in the web.config can be removed if you don't need them, but note you need to remove the Roles from the value part of the setting, we still need the setting it self e.g.
<add key="NewsPublisherRoleName" value="Publishers" />
Change to
<add key="NewsPublisherRoleName" value="" />

As for the default role you need one role as a default role which is used in the MonoX CMS to put the new users in that role and to check the user permissions. So set the DefaultUserRoles setting to your default role.

If you need anything else let us know.

Regards
This content has not been rated yet. 
15993 Reputation 2214 Total posts
manvir-kaur

manvir.kaur

9/13/2011 10:20:24 AM
ddlUserType.SelectedItem.Text has a value (Vendor) which matches with the value of RoleName field in aspnet_Roles table.
For testing purpose I've also tried this code as follows:

Roles.AddUserToRole(this.UserName, 'Vendor');

It gives me same error.
This content has not been rated yet. 
3046 Reputation 388 Total posts
manvir-kaur

manvir.kaur

9/13/2011 10:24:25 AM
Do i also need to re-generate code from LLBLGen Pro, after making any changes in data in Sql Server, like role name?
This content has not been rated yet. 
3046 Reputation 388 Total posts
khorvat

khorvat

9/13/2011 10:33:44 AM
Hi,

no you don't need to regenerate the LLBLGen when you change the data, only when you change the structure. Static objects Roles and Membership are a part of the ASP.NET Membership provider structure and it isn't related to LLBLGen it may be related to Cache optimization used in MonoX layer or misconfiguration of the Membership provider. Can you please send us a web.config file so we can check the configuration ?

Please post your questions to your priority support forum so we can track it there, as I'm closing this public forum topic. Thanks
This content has not been rated yet. 
15993 Reputation 2214 Total posts