SimpleMembershipProvider 不工作 [英] SimpleMembershipProvider not working

查看:20
本文介绍了SimpleMembershipProvider 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 VS2012 启动了一个新的 Internet 项目,并且正在尝试稍微重组我的项目,但我似乎无法让 SimpleMemberhsipProvider 继续工作.基本上,我所做的就是将模型对象与其他几个项目一起移动到核心项目中.我已经实现了 Ninject 并试图通过使用存储库模式来获取我的数据来抽象 Entity .我真的不觉得我对当前项目有太大改变,但出于某种原因,当我现在启动应用程序时,我得到:

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", "UserProfile", "Id", "UserName", autoCreateTables: true);

WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "Id", "UserName", autoCreateTables: true);

被调用.

这是一些堆栈跟踪:

[ProviderException:尚未启用角色管理器功能.]
System.Web.Security.Roles.EnsureEnabled() +9561885
System.Web.Security.Roles.get_Provider() +8
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo连接,字符串 userTableName,字符串 userIdColumn,字符串userNameColumn, Boolean autoCreateTables) +104
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(字符串connectionStringName, String userTableName, String userIdColumn,String userNameColumn, Boolean autoCreateTables) +100
InoutBoard.Core.Infrastructure.Filters.SimpleMembershipInitializer..ctor()在 c:UsersKyleDocumentsVisual Studio2012ProjectsInoutBoardInoutBoard.CoreInfrastructureFiltersInitializeSimpleMembershipAttribute.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:UsersKyleDocumentsVisual Studio 2012ProjectsInoutBoardInoutBoard.CoreInfrastructureFiltersInitializeSimpleMembershipAttribute.cs:42

[InvalidOperationException: ASP.NET Simple Membership 数据库无法初始化.有关更多信息,请参阅http://go.microsoft.com/fwlink/?LinkId=256588]
InoutBoard.Core.Infrastructure.Filters.SimpleMembershipInitializer..ctor()在 c:UsersKyleDocumentsVisual Studio2012ProjectsInoutBoardInoutBoard.CoreInfrastructureFiltersInitializeSimpleMembershipAttribute.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:UsersKyleDocumentsVisual Studio 2012ProjectsInoutBoardInoutBoard.CoreInfrastructureFiltersInitializeSimpleMembershipAttribute.cs:46

我将代码托管在 github 上的以下链接 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:

Add following assemblies to the 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 程序集包含用于初始化成员资格/角色提供程序并启用 RoleManager (PreApplicationStartCode.Start) 的启动方法.但是 ASP.NET 找不到在您的情况下运行的那个.通过添加这两行代码,我们强制 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆