开发者

Custom RoleProvider with MVC 2.0 webconfig

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 appreciat开发者_JAVA技巧ed!


As from the first exception that you got the DashboardRoleProvider needs to have a parameterless constructor. Otherwise the framework isn't able to instantiate your role provider.

In the second example you may want to use the full qualified assembly name instead.

Michael


<add name="SimpleRoleProvider"            type="Dashboard.Web.Controlling.Account.SimpleRoleProvider,Dashboard.Web.Controlling.Account" />

The type part after the first comma is the Assembly name, are you sure your assembly name isn't just Dashboard.Web?

Right click on the project and select properties, that will find your assembly name.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜