ASP.net Membership - Add Role

I need advice on whether it is recommended to add a membership role to a web application after the web application has been deployed and used.

The problem is that the role is created using the ASP.NET Web site administration tool and automatically updates the ASPNETDB database.

The ASPNETDB database in a live environment must then be manually updated to reflect the updated roles. Therefore, as part of the deployment, when the website is down, I will need to update the security database with an additional role and add the database again.

Is this the right way to update roles in a web application after it is deployed?

+7
asp.net-membership roles
source share
3 answers

This code will create the role if it does not exist.

 using System.Web.Security; 

+

 const string newRoleName = "newRoleName"; if (!Roles.RoleExists(newRoleName)) { Roles.CreateRole(newRoleName) }; 

You can skip it on the quick administration page or put it in your Application_Start () application or something like that.

+7
source share

I know this post is pretty old, but I think the easiest way to add a new role is to use a stored procedure as described here

 EXEC aspnet_Roles_CreateRole 'ThisApplication', 'NewRole' 
+5
source share

That is exactly what I did in the past. I will create a SQL script containing updates for the database, in this case there will be an SQL script to insert the data. In addition, if you need to make frequent changes to membership tables, I recommend that you create an interface for this, a simple form of asp.net will work.

+1
source share

All Articles