Asp.net mvc 4 自定义角色提供程序和授权

Asp.net mvc 4 自定义角色提供程序和授权,asp.net-mvc-4,Asp.net Mvc 4,我将跟随关于的教程 在尝试实现自定义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 con

我将跟随关于的教程

在尝试实现自定义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>
这不是更像您想要键入的XML吗?它与

<providers>
<clear/>
<add name="MyroleProvider"type="MvcApplication1.Infrastructure.MyroleProvider"con ectionStringName="DatabaseContext" applicationName="/" />
“连接”一词已分段。

我的问题已解决。 我定义了空项目,并尝试实现自定义RoleProvider。
错误已解决。

噢,此外,为了避免错误,请格式化您的XML/XAML/JSON/Anything。这是开发人员应该做的最基本的事情。要使内容紧凑,请使用模糊器或压缩程序。
<providers>
<clear/>
<add name="MyroleProvider"type="MvcApplication1.Infrastructure.MyroleProvider"con ectionStringName="DatabaseContext" applicationName="/" />