Last post Dec 14, 2014 08:35 PM by Summer - MSFT
Dec 11, 2014 01:07 PM|TechView|LINK
Hello Friends!! Currently I am working with ASP.NET authentication - identity 2 for creating role and membership management. It is a basic problem what I faced given below specifically for creating roles:
Click Event: CreateRole.cs
protected void Button1_Click(object sender, EventArgs e)
var RoleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>(new ApplicationDbContext())); //Database connection - LocalDB
IdentityRole role = new IdentityRole();
role.Name = TextBox1.Text; //User input for role creation
RoleManager.Create(role); //Create role
But the problem is in the following code. It throws an exception:
private RoleStore<IdentityRole> roleStore;
public RoleManager(RoleStore<IdentityRole> roleStore)
// TODO: Complete member initialization
this.roleStore = roleStore;
internal void Create(IdentityRole role)
throw new NotImplementedException(); //Throw exception while running the code
Is there anything that I missed?? I would like to have some ideas in this regard. Thanks.
Dec 12, 2014 02:16 AM|Summer - MSFT|LINK
Welcome to the ASP.NET forum.
So do you want to create a Role for you page.
If so, I think you could use Roles.CreateRole method as the code below.
More information about the Authentication and Identity, please refer to the link below.
Dec 12, 2014 05:07 AM|TechView|LINK
Dec 14, 2014 08:35 PM|Summer - MSFT|LINK
Please first confirm that your configuration is correct in web.config about something of the Membership.
For example about the roleManager:
<roleManager defaultProvider="SARoleProvider" enabled="true" cacheRolesInCookie="true">
<add name="SARoleProvider" type="User.Membership.SARoleProvider" />
Further information please refer to the article.