Last post Jun 22, 2017 09:37 AM by Eric Du
Jun 21, 2017 08:18 AM|DraganSimFin|LINK
I'm upgrading existing web application.
I'm on the way to add roles to application. Application is now efficiently using them in local, but I discovered that roles are not saved in my database in AspNetRoles table but in separate database in ASPNETDB.MDF file. Now I'm looking for a way to switch
roles to my database.
The only part regarding roles in my web.config file is:
As I understood from other sources I need to add something to roleManager element in web.config, but what?
The solution just needs to work. It doesn't needs to be advanced.
Jun 21, 2017 06:41 PM|bbcompent1|LINK
This article helped me before, so it should be of use to you. Check it out and let me know if you need more help:
Jun 21, 2017 07:07 PM|ryanbesko|LINK
Your <roleManager> node should look more like this:
<roleManager enabled="true" defaultProvider="SqlRoleManager" cacheRolesInCookie="true">
<add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServicesContext" applicationName="/Billing" />
Note the connectionStringName element. The value that is there needs to match the name of a connection string defined in the <connectionStrings> node of the same Web.config file. If not you will see the default behavior you are seeing.
Jun 22, 2017 09:37 AM|Eric Du|LINK
According to your description, I think you use button click to insert the user role to the database, but insert to the wrong database.
You need check the following places:
1. the connection string in the web.config, check the data source in this connection string.
2. connectstring name in the button click event, check if is match with the name in the web.config.
For more details, please refer to the following tutorials:
ASP.NET 3.5 - Roles:
If my understanding is wrong, please correct me!