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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:01:31+00:00 2026-05-16T21:01:31+00:00

I have multiple profile providers and profile types: ProviderA with ProfileA and ProviderB with

  • 0

I have multiple profile providers and profile types:

ProviderA with ProfileA
and
ProviderB with ProfileB

They both use a different database. I want to be able to say:

ProfileB.Create(...), and the profile is created in database B, whilst ProfileA.Create(...) creates the profile in database A.

How the hell do I configure this in my web.config?

The following is (of course) invalid:

    <profile inherits="ProfileA, Authenticatie" defaultProvider="ProfileProviderA" enabled="true" automaticSaveEnabled="true">
        <providers>
            <add name="ProfileProviderA" applicationName="websiteA" type="ProfileProviderA, Authenticatie" connectionStringName="connstringA" description=""/>
        </providers>
    </profile>
    <profile inherits="ProfileB, Authenticatie" defaultProvider="ProfileProviderB" enabled="true" automaticSaveEnabled="true">
        <providers>
            <add name="ProfileProviderB" applicationName="websiteB" type="ProfileProviderB, Authenticatie" connectionStringName="connstringB" description=""/>
        </providers>
    </profile>
  • 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-16T21:01:31+00:00Added an answer on May 16, 2026 at 9:01 pm

    I have resolved this with multiple profiles and providers, using the following hack:

    First: create a base class for your profiles. It doesn’t have to contain all the fields; it’s just important they share the same base class (I called this CustomProfileBase).

    Furthermore the following change in config:

    app.config

    <system.web>
        <membership defaultProvider="CustomSqlProviderA" userIsOnlineTimeWindow="15">
            <providers>
                <clear/>
                <add name="CustomSqlProviderA" applicationName="websiteA" type="Authenticatie.A.CustomMembershipProvider, Authenticatie" description="A Membership" connectionStringName="profilesA" />
                <add name="CustomSqlProviderB" applicationName="websiteB" type="Authenticatie.B.CustomMembershipProvider, Authenticatie" description="B Membership" connectionStringName="profilesB" />
            </providers>
        </membership>
        <profile inherits="Authenticatie.CustomProfileBase, Authenticatie" defaultProvider="AProfielen" enabled="true">
            <providers>
                <add name="AProfielen" applicationName="websiteA" type="Authenticatie.A.CustomProfileProvider, Authenticatie" connectionStringName="profielenA" description="A"/>
                <add name="BProfielen" applicationName="websiteB" type="Authenticatie.B.CustomProfileProvider, Authenticatie" connectionStringName="profielenB" description="B"/>
            </providers>
        </profile>
    </system.web>
    

    code

    // find the membershipprovider based on the property 'website'
    var membershipProvider = Membership.Providers.Cast<MembershipProvider>().Single(s => s.ApplicationName == (website == Website.A ? "websiteA" : "websiteB"));
    // find the according profileProvider
    var profileProvider = ProfileManager.Providers[website == Website.A ? "AProfielen" : "BProfielen"];
    
    // here's the hacky part. There is a static field on the ProfileManager
    // that needs to be set. 'Membership' uses the ProfileManager to retrieve
    // and store the profile; so it's pretty much the only way
    FieldInfo cPr = typeof(ProfileManager).GetField("s_Provider", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
    cPr.SetValue(null, profileProvider);
    
    // Now we can retrieve the current user through our selected membershipProvider
    var user = membershipProvider.GetUser(gebruikersData.EmailAdres, false);
    
    if (user == null)
    {
        // create user:
        membershipProvider.CreateUser(mail, password, mail, null, null, true, null, out createStatus);
    
        // create according profile. ProfileBase uses Membership internal.
        var profile = (CustomProfileBase)ProfileBase.Create(mail);
    
        // set the default values, you can upcast your profile again
    
        profile.Save();
    }
    

    Now we have created a user in the according database along with a profile. You can retrieve the user through the membershipProvider and the profile through ProfileManager.FindProfilesByUserName().

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

Sidebar

Related Questions

I want to have multiple path folder structure that contain same name views: /profile.aspx
I have multiple user account types, each with different information. For example, business contacts
We have multiple log files like database log, weblog, quartzlog in our application. Any
I have multiple (8) WAR files and 1 EAR file that I want to
I have multiple functions the do different animations to different parts of the HTML.
I have two tables, Profiles and ProfileInformation . Any profile may have multiple entries
We have a central login that we use to support multiple websites. To store
I have multiple themes on my website and users can just switch between multiple
I have multiple threads who all need to write to the same Dictionary. I
I have multiple DIVs containing an image in each. When I rollover these DIVs,

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.