SimpleMembershipProvider不工作 [英] SimpleMembershipProvider not working

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

问题描述

我开始使用VS2012建立一个新的互联网项目,并尝试只是重组我的项目,我似乎不能保持SimpleMemberhsipProvider的工作。基本上,我所做的一切都是将模型对象与一些其他项目一起移动到一个核心项目中。我已经实现了Ninject,我试图通过使用存储库模式来获取我的数据来抽象Entity。我真的不觉得我现在已经改变了很多项目,但是由于某些原因,当我启动应用程序时,我得到:



框架提供的ActionFilter是当以下情况出现错误:


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


被调用。



这是一些stacktrace:


[ProviderException:角色管理器功能尚未启用。]

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()
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 p>

 < system.web> 
< compilation debug =truetargetFramework =4.5>
< assembly>
< 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)


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."}

The ActionFilter that is supplied by the framework is where the error is thrown when:

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

is called.

Here is some of the 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 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: 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

I'm hosting the code on github at the following link https://github.com/keroger2k/InoutBoard

解决方案

First way

Check the sphair's answer out (in current thread).

Second way

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>

Update

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天全站免登陆