Ninject with MembershipProvider | RoleProvider

半世苍凉 提交于 2019-11-30 13:54:13

I believe this aspect of the ASP.NET framework is very much config driven.

For your last comment, what they mean is that instead of relying on constructor injection (which occurs when the component is being created), you can use setter injection instead, e.g:

public class BasicRoleProvider : RoleProvider
{
  public BasicRoleProvider() { }

  [Inject]
  public IMyService { get; set; }
}

It will automatically inject an instance of your registered type into the property. You can then make the call from your application:

public void Application_Start(object sender, EventArgs e)
{
  var kernel = // create kernel instance.
  kernel.Inject(Roles.Provider);
}

Assuming you have registered your role provider in the config. Registering the provider this way still allows great modularity, as your provider implementation and application are still very much decoupled.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!