How do I control MembershipProvider instance creation/lifetime?

前端 未结 2 876
暗喜
暗喜 2020-12-03 19:13

I have registered a custom MembershipProvider class in my Web.Config file. I\'m using Inversion Of Control using Castle Windsor and I have registered my custom MembershipPro

相关标签:
2条回答
  • 2020-12-03 19:58

    I just blogged about this with a solution.

    In a nutshell, this solution involves a simple, reusable MembershipProvider that calls the container to resolve your custom MembershipProviders. Unlike other solutions that use "BuildUp" container features, this one takes true control of instantiation, thus enabling constructor injection (which in turn enables immutability) and proxyability.

    0 讨论(0)
  • 2020-12-03 20:01

    Don't worry about your MembershipProvider lifetime. Simply manage the lifetime of the IMyService within the provider. Create a property for your IMyService with a getter, and return a new instance (or however you want to manage the lifetime) each time it is requested.

    0 讨论(0)
提交回复
热议问题