1

I'm trying to add roles programatically using Sql Membership Provider, like show below:

string newRoleName = RoleName.Text.Trim();

        if (!Roles.RoleExists(newRoleName))
        {
             // Create the role 
            Roles.CreateRole(newRoleName); 
            RoleName.Text = string.Empty;
        }

I added this namespaces:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.ApplicationServices;

I'm getting the following error:

The type or namespace name 'RoleExists' does not exist in the namespace (are you missing an assembly reference?)

How can I resolved that?

gvd
  • 1,482
  • 6
  • 32
  • 58
  • Are you able to access and use other aspects of the membership provider like MembershipUser CreateUser etc. Or do these error out as well? – Full Time Skeleton Jul 04 '13 at 15:21
  • I can CreateUser and Login... but when I tried to use the Role.(some method) I'm got the error mention above. Any idea why is passing that? – gvd Jul 04 '13 at 15:29
  • And have you got the rolemanager enabled in the web.config? – Full Time Skeleton Jul 04 '13 at 15:52
  • Yes is enable... I achieved do resolved this problem.... But I had that used the absolute route for access to the Roles's Methods.... ystem.Web.Security.Roles.(Role Method)... Why you beleive that is not added to "using" System.Web.Security? – gvd Jul 04 '13 at 18:03

0 Answers0