在SimpleMembership中仅关闭角色提供程序 [英] Turning off only the Role Provider in SimpleMembership
问题描述
我已经阅读了许多不同的文章和教程,却找不到满足此特定需求的答案.
I have read a ton of different posts and tutorials and couldn't find an answer to this specific need.
我想在我的ASP.NET MVC应用程序中使用SimpleMembership
提供程序,但是我想关闭Role提供程序(因为我不会使用OAuth,所以也是OAuth) .这意味着我希望SMP在初始化时仅创建webpages_Membership
表,而不是用于oauth或角色的表.
I'd like to use the SimpleMembership
provider in my ASP.NET MVC app, but I would like to turn the Role provider off (OAuth too since I will not be using it). That means that I would like the SMP to create only webpages_Membership
table on initialization, not the tables for oauth or roles.
请注意,我不想关闭SimpleMembership,仅要关闭角色和oauth支持.
Note that I don't want to turn off the SimpleMembership, only the roles and the oauth support.
问题:可以通过配置实现这种情况吗?
Question: Can such a scenario be achieved by configuration?
尝试:
我已经尝试通过在web.config
(每个它所属的地方)中进行设置:
Attempt:
I've tried by setting this in web.config
(each where it belongs):
< add key="enableSimpleMembership" value="false" />
< roleManager enabled="false" >
,但是InitializeSimpleMembershipAttribute
在LazyInitializer.EnsureInitialized
处的终止符为:
but then the InitializeSimpleMembershipAttribute
breaks on LazyInitializer.EnsureInitialized
with:
Exception has been thrown by the target of an invocation.
|
└> The ASP.NET Simple Membership database could not be initialized
|
└> The Role Manager feature has not been enabled.
这是完全正确的,但这正是我想要的.有什么方法可以告诉SimpleMembership完全不使用角色提供程序,同时仍然保留WebSecurity的其他功能,例如登录其他成员身份?
which is completely true, but that's exactly what I want. Is there some way to tell the SimpleMembership not to use the Role Provider at all, while still retaining other features of WebSecurity's such as login other membership stuff?
推荐答案
简单成员资格API不是松散耦合的体系结构,因此全部包含在WebSecurity程序集中.角色管理器将被延迟实例化,并且可以选择使用它或并不完全取决于你.只要您不使用UserInRole方法,就不会实例化角色提供程序.实际上,性能没有任何损失. 因此,您可以直接使用简单成员资格,而无需使用角色提供程序,而不必担心将其关闭.
The Simple Membership API is not a loosely coupled architecture so it all comes in the WebSecurity assembly.The role manager will be instantiated lazily and the option of using it or not completely lies with you. As long as you're not using UserInRole methods, the role provider is not instantiated. In effect there is no loss in performance. Thus you can just go ahead and use Simple Membership without using the role provider without worrying about turning it off.
这篇关于在SimpleMembership中仅关闭角色提供程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!