Custom RoleProvider with MVC 2.0 webconfig

Posted by Farrell on Stack Overflow See other posts from Stack Overflow or by Farrell
Published on 2010-03-11T18:44:54Z Indexed on 2010/03/11 20:44 UTC
Read the original article Hit count: 840

Filed under:
|
|
|

I have a custom MembershipProvider and a custom RoleProvider. I created the custom MembershipProvider by creating a SimpleMembershipProvider class which implements the MembershipProvider class. After that I changed my web.config and works.

So I used the same approach creating a custom RoleProvider. Nothing special, just creating a SimpleRoleProvider class which implements the RoleProvider class. But then when I changed the web.config file and runs the solution I get the following error message:

Web.Config

<membership defaultProvider="DashboardMembershipProvider">
<providers>
    <clear/>
    <add name="SimpleMembershipProvider" 
        type="Dashboard.Web.Controlling.Account.SimpleMembershipProvider" />
    </providers>
</membership>

<roleManager enabled="true" defaultProvider="DashboardRoleProvider">
    <providers>
        <clear/>
        <add name="DashboardRoleProvider" 
            type="Dashboard.Web.Controlling.Account.DashboardRoleProvider" />
    </providers>
</roleManager>


Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: No parameterless constructor defined for this object.

Source Error
Line 78:         <add name="SimpleRoleProvider" 
Line 79:            type="Dashboard.Web.Controlling.Account.SimpleRoleProvider" />

So I searched the web. And tried on the type attribute, which generates the following errors:

 Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load file or assembly 'Dashboard.Web.Controlling.Account' or one of its dependencies. The system cannot find the file specified.

Source Error:
Line 78:         <add name="SimpleRoleProvider" 
Line 79:              type="Dashboard.Web.Controlling.Account.SimpleRoleProvider,Dashboard.Web.Controlling.Account" />

Any suggestions on how I would be able to get this CustomRoleProvider working? Any help is greatly appreciated!

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about web.config