【问题标题】:Custom RoleProvider and Authorization自定义 RoleProvider 和授权
【发布时间】:2015-11-04 13:38:44
【问题描述】:

我正在关注this site 上的教程。

在尝试实现自定义 RoleProvider 时,我收到以下错误。

Server Error in '/' Application

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: This
method cannot be called during the application's pre-start
initialization phase

来源错误:

<providers>
    <clear/> 
    <add name="MyroleProvider"type="MvcApplication1.Infrastructure.MyroleProvider"con ectionStringName="DatabaseContext" applicationName="/" />
</providers>

我已将 web.config 部分更新为以下内容,但仍然出现错误。

<roleManager enabled="true"  cacheRolesInCookie="true" defaultProvider="MyroleProvider">
  <providers>
    <clear/>
   <add name="MyroleProvider" type="MvcApplication1.Infrastructure.MyroleProvider" connectionStringName="DatabaseContext" applicationName="/" />
  </providers>
</roleManager>

【问题讨论】:

    标签: asp.net-mvc-4


    【解决方案1】:
    <providers>
        <clear/> 
        <add name="MyroleProvider" type="MvcApplication1.Infrastructure.MyroleProvider" connectionStringName="DatabaseContext" applicationName="/" />
        . . .
    </providers>
    

    这不是更像你想要输入的 XML 吗?不一样

    <providers>
    <clear/>
    <add name="MyroleProvider"type="MvcApplication1.Infrastructure.MyroleProvider"con ectionStringName="DatabaseContext" applicationName="/" />
    

    单词连接是分段的。

    【讨论】:

    • 哦,此外,为避免错误,请格式化您的 XML/XAML/JSON/Anything。这是开发人员应该做的最基本的事情。要紧凑,请使用混淆器或压缩器。
    【解决方案2】:

    我的问题解决了。 我定义了空项目并尝试实现自定义角色提供者。 错误已解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-07-04
      • 1970-01-01
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      • 2015-01-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多