开发者

Error getting WCF to load a custom RoleProvider

I've been trying to get a custom role provider working for my WCF services. They are hosted in IIS 7, but no matter what I do I can't seem to get them to actually work. I just get the Default Role Provider could not be found. error. My web.config looks like this:

  <system.web>
    <compilation debug="false" targetFramework="4.0" />
    <roleManager enabled="true" defaultProvider="CustomValidators.WaveRoleProvider, CustomValidators">
      <providers>
        <clear/>
        <add name="test" type="CustomValidators.WaveRoleProvider, CustomValidators"/>
      </providers>
    </roleManager>
  </system.web>

The actual function that provides the RoleProvider is as follows.

namespace CustomValidators
{
  public class WaveRoleProvider : RoleProvider
  {
    public override string[] GetRolesForUser(string username)
    {
      return string[0];
    }

    public override bool IsUserInRole(string username, string roleName)
    {
      return true;
    }

    public override void AddUsersToRoles(string[] usernames, string[] roleNames)
    {
      return;
    }

    public override string ApplicationName
    {
      get
      {
        return "test";
      }
      set
      {
      }
    }

    public override void CreateRole(string roleName)
    {
      return;
    }

    public override bool DeleteRole(string roleName, bool throwOnPopulatedRole)
    {
      return true;
    }

    public override string[] FindUsersInRole(string roleName, string usernameToMatch)
    {
      return new string[0];
    }

    public override string[] GetAllRoles()
    {
      return new string[0];
    }

    public override string[] GetUsersInRole(string roleName)
    {
      return new string[0];
    }

    public override void RemoveUsersFromRoles(string[] usernames, string[] roleNames)
    {
      return;
    }

    public override bool RoleExists(string roleName)
    {
      return true;
    }
  }
}

Obviously I'll eventually fill all these out with actual logic instead of just returning dummy data, but this should at least load.

I've checked and IIS does load the assembly like it should, and if I rename either the class or the assembly it generates a different error, so I'm pretty sure that everything开发者_开发知识库 is loaded as it should, but no matter what I try I always get the Default Role Provider could not be found. I've been googling this, and checked on Stack Overflow, but I can't seem to find out why this is. I realize that right now my class is pretty basic, but


Fixed my own issue. The problem was that I should have pointed to the name of my provider in my defaultProvider instead of the class.

<system.web>
    <compilation debug="false" targetFramework="4.0" />
    <roleManager enabled="true" defaultProvider="test">
      <providers>
        <clear/>
        <add name="test" type="CustomValidators.WaveRoleProvider, CustomValidators"/>
      </providers>
    </roleManager>
  </system.web>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜