Get role list from Web.Config


var res = new List<string>();
var conf = WebConfigurationManager.GetSection("system.web/authorization");
if (conf != null)
{
    var sec = (AuthorizationSection)conf;
    foreach (AuthorizationRule r in sec.Rules)
    {
        if (r.Action == AuthorizationRuleAction.Allow)
        {
            var p = r.ElementInformation.Properties["roles"];
            if (p != null)
            {
                if (p.ValueOrigin != PropertyValueOrigin.Inherited)
                {
                    string val = p.Value.ToString();
                    if (!string.IsNullOrEmpty(val))
                    {
                        string[] roles = val.Split(',');
                        foreach (string roleStr in roles)
                        {
                            string roleVal = roleStr.Trim();
                            if (roleVal != string.Empty)
                            {
                                res.Add(roleVal);
                            }
                        }
                        break;
                    }
                }
            }
        }
    }
}