ASP.NET Identity – how to get all roles and how to delete a role

asp.net-identity

I am using Asp.net Identity with Web Forms in VS 2013 Express for Web.
I am referring to this AspIdentitySample example at https://github.com/rustd/AspnetIdentitySample
The example is with MVC.
To get all roles and to delete a role, they use:

RoleManager.Roles()RoleManager.DeleteAsync()

But I cannot find these two methods in my RoleManager – I mean they don't appear in Intellisense at all.
Are they only available in MVC, but not in Web Forms?

I am very frustrated with this Asp.net Identity stuff, is there any ASP.NET Identity books so that I can learn?

Best Solution

This is how i get the roles in a dropdownlist

            var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>());            var roles = roleManager.Roles.ToList();            dropRolesDelete.DataTextField = "Name";            dropRolesDelete.DataValueField = "Id";            dropRolesDelete.DataSource = roles;            dropRolesDelete.DataBind();

And this is how i use the dropdown list to delete a role

   try        {            var selecteditem = dropRolesDelete.SelectedItem.ToString();            var roleManager = new RoleManager<IdentityRole>(new RoleStore<IdentityRole>());            var role = roleManager.FindByName(selecteditem);            roleManager.Delete(role);            lblResult.Text = "Lucky"        }        catch (Exception ex)        {            lblResult.Text = ex.Message;        }

you may have to include this if you dident already

using ASP.NET_Identity.Models;using Microsoft.AspNet.Identity;using Microsoft.AspNet.Identity.EntityFramework;