0

就像标题所说的roleManager有错误

这是 web.config 代码:

<roleManager enabled="true" defaultProvider="MyProvider">
      <providers>
        <add name="MyProvider" type="TrollMarket.web.MyRoleProvider.RoleSite"/>
      </providers>
    </roleManager>

这是文件位置

这是 GetRoleForUser

public override string[] GetRolesForUser(string username) {
            AccountProvider accountProvider = new AccountProvider();
            string role = accountProvider.GetRole(username);
            string[] result = { role };
            return result;
        }

这是getrole函数

public string GetRole(string username) {
        var user = trollContext.Account.FirstOrDefault(acc => acc.username == username);
        return user.role;
    }

请教我如何解决它这是我的前辈的一项任务,由于这个错误我无法获得这个角色

这是错误

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 type 'TrollMarket.web.MyRoleProvider.RoleSite'.

Source Error:

Line 26:     <roleManager enabled="true" defaultProvider="MyProvider">
Line 27:       <providers>
Line 28:         <add name="MyProvider" type="TrollMarket.web.MyRoleProvider.RoleSite"/>
Line 29:       </providers>
Line 30:     </roleManager>
4

1 回答 1

0

没关系,我找到了答案,对于那些有同样问题的人,请检查您的提供程序命名空间并根据命名空间更改类型,如下所示

<add name="MyProvider" type="namespace.MyRoleProvider.RoleSite"/>
于 2020-05-19T13:29:29.943 回答