1

我知道我可以使用如下代码获得对 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 对象模型不同,我无法弄清楚。谢谢你的帮助!

罗杰·马丁

图库服务器专业版

4

1 回答 1

-2

在 .net 框架中使用 ProfileManager 类

于 2010-02-02T12:21:50.853 回答