By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

multiple profile providers in single web application

P: n/a
Hi:

I have been trying to create a web application that provides suport
for two membership/profile databases: one for private users and one
for another set of users. These tw user have a totally different set
of profile attributes.

I added the following code to my web.config (under system.web):

<membership defaultProvider="PortalMembershipProvider">
<providers>
<remove name="PortalMembershipProvider"/>
<remove name="PublicMembershipProvider"/>
<add name="PortalMembershipProvider"
type="System.Web.Security.SqlMembershipProvider... "
connectionStringName="LocalSqlServer" .../>
<add name="PublicMembershipProvider"
type="System.Web.Security.SqlMembershipProvider... "
connectionStringName="PublicUserProfiles" .../>
</providers>
</membership>
<profile defaultProvider="PortalProfileProvider">
<providers>
<remove name="PortalProfileProvider"/>
<remove name="PublicProfileProvider"/>
<add name="PortalProfileProvider"
connectionStringName="LocalSqlServer" .../>
<add name="PublicProfileProvider"
connectionStringName="PublicUserProfiles" .../>
</providers>
<properties>
<add provider="PortalProfileProvider" name="FirstName"
type="System.String" serializeAs="Xml"/>
<add provider="PortalProfileProvider" name="LastName"
type="System.String" serializeAs="Xml"/>
<group name="PhoneNumbers">
<add provider="PublicProfileProvider" name="Phone"
type="System.String" serializeAs="Xml"/>
<add provider="PublicProfileProvider" name="Fax"
type="System.String" serializeAs="Xml"/>
</group>
</properties>
</profile>
<roleManager defaultProvider="PortalRoleProvider" enabled="true">
<providers>
<add name="PortalRoleProvider"
connectionStringName="LocalSqlServer" .../>
<add name="PublicRoleProvider"
connectionStringName="PublicUserProfiles" .../>
</providers>
</roleManager>

All connection string names and values have been verified.

I try to add a user via the Membership API, targeting a specific
provider from above, I use the following code:
MembershipCreateStatus status;
user =
Membership.Providers["PortalMembershipProvider"].CreateUser(username,
password, email, "", "", true, Guid.NewGuid(), out status);
This works without issue.

I do the same ting for adding the new user to a role:

Roles.Providers["PortalRoleProvider"].AddUsersToRoles(userStringArray,
roleStringArray);
This works without issue as well.

Now here is the problem. When I try to perform a similar action to
add a profile for the new user, I use the following code:
section =
(ProfileSection)WebConfigurationManager.GetSection ("system.web/
profile");
profile.Providers["PortalProfileProvider"].Initialize(

user.UserName,

section.Providers["PortalProfileProvider"].Parameters
);

I recieve an error stating that the profile provider "reference is not
set to an instance of an object."

Is there any way to get around this?

Best Regards,
Mike

Jun 27 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
one profile, use fields as needed with 2 roles....
"Mike" <mi***********@gmail.comwrote in message news:11*********************@n60g2000hse.googlegro ups.com...
Hi:

I have been trying to create a web application that provides suport
for two membership/profile databases: one for private users and one
for another set of users. These tw user have a totally different set
of profile attributes.>
....
Is there any way to get around this?


Jun 27 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.