I can't seem to figure out how to get dependency injection to work in a custom membership provider. I'm aware that the membership provider base class is managed deep in ASP.NET, but there should be some way to get dependency injection to work on private data members.
I'm using Unity and see this issue only in my membership and role providers
my issue is two fold:
- The application complains that it doesn't have a parameterless constructor for "MyMembershipProvider"
even if I try this: https://stackoverflow.com/a/9815425/595335, security service is null in the ValidateUser method
public class MyMembershipProvider : MembershipProvider { public ISecurityService securityService; public MyMembershipProvider(ISecurityService securityService) { this.securityService = new SecurityService(); } public override bool ValidateUser(string username, string password) { User user = securityService.GetUserByUsername(username); ...ommited... }