Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3788686
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:02:19+00:00 2026-05-19T12:02:19+00:00

I’m using Autofac with ASP.NET MVC so all my controllers have their dependencies resolved

  • 0

I’m using Autofac with ASP.NET MVC so all my controllers have their dependencies resolved nicely. But I have a custom membership provider with two dependencies. I suspect that the code to instantiate the membership provider is deep in ASP.NET, miles away from Autofac.

Is there a way to get Autofac to resolve my custom membership provider?

I assume that calling something like .Resolve

Here is the membership provider and its constructor :

public class MongoDBMembershipProvider : MembershipProvider
{
    private IEmailService m_oEmailService;
    private IUserRepository m_oUsers;

    public MongoDBMembershipProvider() {
    }

    public MongoDBMembershipProvider( IEmailService oEmailservice, IUserRepository oUserRepository) {
        m_oEmailService = oEmailservice;
        m_oUsers = oUserRepository;
    }

    public override void Initialize( string name, NameValueCollection config) {
        //TODO: Let Autofac do this work... how?
        m_oEmailService = new EmailService();
        m_oUsers = new Users();
    }

    public override bool ValidateUser( string sUsername, string sPassword) {
        return m_oUsers.ValidateAttemptedLogon( sUsername, sPassword);
    }

    public override string GetUserNameByEmail( string sEmailAddress) {
        return m_oUsers.GetUsernameByEmail( sEmailAddress);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:02:19+00:00Added an answer on May 19, 2026 at 12:02 pm

    Even though asp.net membership providers are static, you can still wrap them in an interface. The one that I have been using is here:

    http://gpsnerd.codeplex.com/SourceControl/changeset/view/03279dbfcef5#Infrastructure%2fMembership%2fIMembershipService.cs

    You would then create an implementation of this interface that uses the asp.net membership. Then you can let your ioc bind this interface to the implementation. By extracting out this interface, now you can test your code using a fake.

    bob

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
In order to apply a triggered animation to all ToolTip s in my app,
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.