SimpleMembershipProvider不工作 [英] SimpleMembershipProvider not working
问题描述
我开始用VS2012一个新的互联网项目,我试图只是调整自己的项目了一下,我似乎无法保持SimpleMemberhsipProvider工作。基本上,所有我所做的就是移动模型对象转换成一个核心项目与其他几个项目一起。我实现了Ninject和我通过使用存储库模式让我的数据试图抽象实体一点。我真的不觉得好像我已经改变了很多与当前项目,但由于某些原因,当我现在启动应用程序我得到:
I started a new internet project with VS2012 and am trying to just restructure my project a bit and I can't seem to keep the SimpleMemberhsipProvider working. Basically, all I've done is move the models objects into a core project along with a couple other items. I've implemented Ninject and am trying to abstract Entity a bit by using a repository pattern to get my data. I really don't feel as though I've changed much with the current project, but for some reason when I start the application now I get:
{角色管理器功能尚未启用。}
{"The Role Manager feature has not been enabled."}
这是由框架提供的ActionFilter是哪里的错误被抛出时:
The ActionFilter that is supplied by the framework is where the error is thrown when:
WebSecurity.InitializeDatabaseConnection(DefaultConnection,用户配置,ID,用户名,autoCreateTables:真正的);
WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "Id", "UserName", autoCreateTables: true);
被调用。
下面是一些堆栈跟踪的:
Here is some of the stacktrace:
[ProviderException:角色管理器功能尚未启用]结果
System.Web.Security.Roles.EnsureEnabled()9561885结果
System.Web.Security.Roles.get_Provider()+8结果
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo
连接,字符串userTableName,字符串userIdColumn,字符串
userNameColumn,布尔autoCreateTables)+104结果
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(字符串
的connectionStringName,字符串userTableName,字符串userIdColumn,
串userNameColumn,布尔autoCreateTables)+100结果
InoutBoard.Core.Infrastructure.Filters.SimpleMembershipInitializer..ctor()
在C:\\用户\\凯尔\\文档\\ Visual Studio的
2012\\Projects\\InoutBoard\\InoutBoard.Core\\Infrastructure\\Filters\\InitializeSimpleMembershipAttribute.cs:42
[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 userTableName, String userIdColumn, 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:ASP.NET的简单的会员数据库
不能被初始化。欲了解更多信息,请参阅
http://go.microsoft.com/fwlink/?LinkId=256588]结果
InoutBoard.Core.Infrastructure.Filters.SimpleMembershipInitializer..ctor()
在C:\\用户\\凯尔\\文档\\ Visual Studio的
2012\\Projects\\InoutBoard\\InoutBoard.Core\\Infrastructure\\Filters\\InitializeSimpleMembershipAttribute.cs:46
[InvalidOperationException: The ASP.NET Simple Membership database
could not be initialized. For more information, please see
http://go.microsoft.com/fwlink/?LinkId=256588]
InoutBoard.Core.Infrastructure.Filters.SimpleMembershipInitializer..ctor()
in c:\Users\Kyle\Documents\Visual Studio
2012\Projects\InoutBoard\InoutBoard.Core\Infrastructure\Filters\InitializeSimpleMembershipAttribute.cs:46
我托管在GitHub上code以下链接 https://github.com/keroger2k/InoutBoard
I'm hosting the code on github at the following link https://github.com/keroger2k/InoutBoard
推荐答案
第一种方式
检查 sphair的回答的输出(在当前线程中)。
Check the sphair's answer out (in current thread).
方式二
添加下列程序集到的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, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
</system.web>
更新
的 WebMatrix.WebData code>集包含启动方法来初始化会员/角色提供并启用RoleManager(
preApplicationStart code 。开始
)。但是ASP.NET无法找到您的情况运行。通过添加code这两种界限,我们强迫ASP.NET来搜索这些程序集 preApplicationStartMethodAttribute(S)
。
The WebMatrix.WebData
assembly contains a start up method to initialize Membership/Role providers and enable RoleManager (PreApplicationStartCode.Start
). But ASP.NET couldn't find that to run in your case. By adding these two lines of code, we force ASP.NET to search these assemblies for PreApplicationStartMethodAttribute(s)
.
这篇关于SimpleMembershipProvider不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!