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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:14:58+00:00 2026-05-12T08:14:58+00:00

I am pretty new to the NInject binding, and here is what NInject describes.

  • 0

I am pretty new to the NInject binding, and here is what NInject describes.

  • TransientBehavior-A new instance of the type will be created each time one is requested.
  • SingletonBehavior-Only a single instance of the type will be created, and the same instance will be returned for each subsequent request.
  • OnePerThreadBehavior-One instance of the type will be created per thread.
  • OnePerRequestBehavior-One instance of the type will be created per web request, and will be destroyed when the request ends.

If I want to bind MembershipProvider to SqlMembershipProvider, should I use SingletonBehavior since I only need one sql membership provider?

  • 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-12T08:14:58+00:00Added an answer on May 12, 2026 at 8:14 am

    ASP.Net already provides a static instance of the current membership provider via the static Membership class and its static Provider property. The binding would likely be in your Application_Start method and look something like this:

    Bind<MembershipProvider>()
      .ToMethod(ctx => Membership.Provider);
    

    Again, because the Memberhip.Provider is a static, it’s sort of like a singleton already, so the behavior you try to apply doesn’t really matter as much.

    By not specifying any behavior in the above snippet, Ninject will default to a transient behavior. In this sort of a binding, I believe that will amount to calling the lambda that returns Membership.Provider every time it needs to inject a MembershipProvider type.

    I suppose there could be an argument for explicitly specifying a singleton behavior as Ninject would likely “cache” the value returned by the lambda the first time it needs to inject a MembershipProvider, in effect saving the overhead of executing the lambda. I’m not 100% sure that’s how Ninject would work in this situation, but it seems reasonable that it would.

    All that said, my personal preference would be to use OnePerRequestBehavior, this way I know Ninject will call my lambda once for each request. Not sure it’s necessary, but I like the idea of getting the provider from Membership.Provider once each request since I suppose you can’t make assumptions about how or when Membership.Provider get’s set, though you could probably find out if you dig enough with Reflector.

    Bind<MembershipProvider>()
      .ToMethod(ctx => Membership.Provider)
      .Using<OnePerRequestBehavior>();
    

    Good luck. Sorry your question sat out here so long!

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

Sidebar

Related Questions

I'm a pretty new C# and .NET developer. I recently created an MMC snapin
Pretty new here. But before I ask my question, I'm not looking for teh
Pretty new to sqlite (and sql). Trying to modify one table using another. create
Im pretty new to CI so bear with me here. I have just setup
Pretty new to rails/heroku. I created a clean project to help figure out what
Pretty new flixel/AS3 user here, though not entirely new to coding. Anyways, the error
Pretty new to Dynamics CRM 2011. I'm creating a data integration with Dynamics CRM
Im pretty new to Java Web Services, but I cant find a good explanation
I pretty new to Objective-C (and C itself) and need to consume a NSData
I'm pretty new to Ruby and Rails but even after searching stack overflow and

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.