{“The Role Manager feature has not been enabled.”}
框架提供的ActionFilter是在以下情况下抛出错误的地方:
WebSecurity.InitializeDatabaseConnection(“DefaultConnection”,“UserProfile”,“Id”,“UserName”,autoCreateTables: true);
叫做。
这里有一些stacktrace:
[ProviderException: The Role Manager feature has not been enabled.]
System.Web.Security.Roles.EnsureEnabled() +9561885
System.Web.Security.Roles.get_Provider() +8
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo
connect,String userTableName,String userIdColumn,String
userNameColumn,Boolean autoCreateTables) +104
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String
connectionStringName,
String userNameColumn,Boolean autoCreateTables) +100
InoutBoard.Core.Infrastructure.Filters.SimpleMembershipInitializer..ctor()
in c:\Users\Kyle\Documents\Visual Studio
2012\Projects\InoutBoard\InoutBoard.Core\Infrastructure\Filters\InitializeSimpleMembershipAttribute.cs:42[InvalidOperationException: The ASP.NET Simple Membership database
could not be initialized. For more information,please see
07000
InoutBoard.Core.Infrastructure.Filters.SimpleMembershipInitializer..ctor()
in c:\Users\Kyle\Documents\Visual Studio
2012\Projects\InoutBoard\InoutBoard.Core\Infrastructure\Filters\InitializeSimpleMembershipAttribute.cs:46
我在github上的代码在以下链接https://github.com/keroger2k/InoutBoard
解决方法
检查sphair’s answer出(在当前线程)。
第二种方式
将以下程序集添加到web.config中:
<system.web> <compilation debug="true" targetFramework="4.5"> <assemblies> <add assembly="WebMatrix.Data,Version=2.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35"/> <add assembly="WebMatrix.WebData,PublicKeyToken=31bf3856ad364e35"/> </assemblies> </compilation> </system.web>
更新
WebMatrix.WebData程序集包含一个初始化成员资格/角色提供程序并启用RoleManager(PreApplicationStartCode.Start)的启动方法。但ASP.NET找不到在你的情况下运行。通过添加这两行代码,我们强制ASP.NET搜索这些程序集以获取PreApplicationStartMethodAttribute(s)。