views:

227

answers:

2

I know I can get a reference to the default Profile in ASP.NET with code like this:

ProfileBase p = ProfileBase.Create(username);

(I know there is also HttpContext.Current.Profile, but that is for the current user, and I need to get the profile by username.)

The above code works only for the DEFAULT provider as defined in the defaultProvider attribute in web.config:

<profile defaultProvider="SqlProfileProvider">
<providers>
 <clear />
 <add applicationName="Gallery Server Pro" connectionStringName="SQLiteDbConnection"
 name="SQLiteProfileProvider"     type="GalleryServerPro.Data.SQLite.SQLiteProfileProvider" />
 <add applicationName="Gallery Server Pro" connectionStringName="SqlServerDbConnection"
 name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" />
</providers>
<properties>
 <add name="ShowMediaObjectMetadata" defaultValue="false" type="String" allowAnonymous="true" />
 <add name="UserAlbumId" defaultValue="0" type="Int32" allowAnonymous="false" />
 <add name="EnableUserAlbum" defaultValue="true" type="String" allowAnonymous="false" />
</properties>
</profile>

How would I get a reference to a non-default provider? For example, the provider named SQLiteProfileProvider shown above? I have it working for roles and membership:

RoleProvider rp = Roles.Providers["SQLiteRoleProvider"];

But the Profile object model is different and I can't figure it out. Thanks for any help!

Roger Martin

Gallery Server Pro

A: 

Use ProfileManager class in .net framework

mmtemporary
A: 

I too am looking for the answer to this question. Using the ProfileManager class returns back a ProfileInfo object that does not contain any of the properties defined in the web.config. I think what I am looking for is for a method to return me a ProfileBase object that I can then get properties from.

Sammy