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 772747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:51:04+00:00 2026-05-14T18:51:04+00:00

I was using the default AspNetSqlMembershipProvider in my application. Authentication is performed via an

  • 0

I was using the default AspNetSqlMembershipProvider in my application. Authentication is performed via an AuthenticationService (since I’m also supporting other forms of membership like OpenID).

My AuthenticationService takes a MembershipProvider as a constructor parameter and I am injecting the dependency using StructureMap like so:

For<MembershipProvider>().Use(Membership.Provider);

This will use the MembershipProvider configured in web.config. All this works great.

However, now I have rolled my own MembershipProvider that makes use of a repository class. Since the MembershipProvider isn’t exactly IoC friendly, I added the following code to the MembershipProvider.Initialize method:

_membershipRepository = ObjectFactory.GetInstance<IMembershipRepository>();

However, this raises an exception, like StructureMap hasn’t been initialized (cannot get instance of IMembershipRepository). However, if I remove the code and put breakpoints at my MembershipProvider’s initialize method and my StructureMap bootstrapper, it does appear that StructureMap is configured before the MembershipProvider is initialized.

My only workaround so far is to add the above code to each method in the MembershipProvider that needs the repository. This works fine, but I am curious as to why I can’t get my instance in the Initialize method. Is the MembershipProvider performing some internal initialization that runs before any of my own application code does?

Thanks
Ben

  • 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-14T18:51:06+00:00Added an answer on May 14, 2026 at 6:51 pm

    Yes, the provider is initialized by the ASP.Net runtime when the AppDomain is spun up, far in advance of any execution of your code.

    You will need to choose another point to do your composition, perhaps in Global.Application_???.

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

Sidebar

Related Questions

I'm developing an application using ASP.NET 4 MVC 3. I'm using the default AspNetSqlMembershipProvider.
So, I am converting an application from integrated security to forms authentication using the
I'm using default drag and drop inside a backbone application i'm listening event in
I'm using default route of mvc2 like {controller}/{action}/{id} . I want to access that
Well, in my application I'm using default camera and gallery of Android with startActivityforResult
Do you know any cross-platform GUI toolkit like swt for C (using default widgets
What's the best way to get a reference to other views using default controllers?
I am developing an application in which i have to send email using default
Presently I am developing Android application for Samsung galaxy tab. I am using default
I have created application using: Default Web Site >> Right Click >> Add Application

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.