title: Inject Multiple MembershipProviders with Structuremap
body: <p>I have an existing ASP.NET MVC application and am using StructureMap as my IOC container of choice. Currently when a controller needs an IMembershipProvider I use StructureMap to inject a concrete instance in the controller's constructor based on the BuyerMembershipProvider configuration from my web.config file as in the below solution code:</p>
  
  <pre><code>ObjectFactory.Initialize(x =&gt;
  {
          x.ForRequestedType&lt;IMembershipService&gt;().TheDefaultIsConcreteType&lt;AccountMembershipService&gt;();
      x.ForRequestedType&lt;IFormsAuthentication&gt;().TheDefaultIsConcreteType&lt;FormsAuthenticationService&gt;();
      x.ForRequestedType&lt;MembershipProvider&gt;().TheDefault.IsThis(SecurityProvider.Providers["BuyerMembershipProvider"]);
  });
  </code></pre>
  
  <p>This works fine. However, it is bound to the "buyer" user type. Seller information is stored in a different database and will have different tables to store membership information. Essentially, I would like to be able to inject either a BuyerMembershipProvider or a SellerMembership Provider based on context and have the following in my objectfactory initialization:</p>
  
  <pre><code>x.ForRequestedType&lt;MembershipProvider&gt;().TheDefault.IsThis(SecurityProvider.Providers["BuyerMembershipProvider"]);
  x.ForRequestedType&lt;MembershipProvider&gt;().TheDefault.IsThis(SecurityProvider.Providers["SellerMembershipProvider"]);
  </code></pre>
  
  <p>Is it possible to decide between two concrete implementations when initializing the objectfactory?</p>
  
  <p>Any help is greatly appreciated,
  Thanks in advance!
  JP</p>