次のようなコードを使用して、ASP.NET の既定のプロファイルへの参照を取得できることを知っています。
ProfileBase p = ProfileBase.Create(username);
(HttpContext.Current.Profile もあることは知っていますが、それは現在のユーザー用であり、ユーザー名でプロファイルを取得する必要があります。)
上記のコードは、web.config の defaultProvider 属性で定義されている DEFAULT プロバイダーに対してのみ機能します。
<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>
デフォルト以外のプロバイダーへの参照を取得するにはどうすればよいですか? たとえば、上記の SQLiteProfileProvider という名前のプロバイダーは? 私はそれを役割とメンバーシップのために機能させています:
RoleProvider rp = Roles.Providers["SQLiteRoleProvider"];
しかし、Profile オブジェクト モデルは異なり、私には理解できません。助けてくれてありがとう!
ロジャー・マーティン