【问题标题】:How to get a reference to a non-default ProfileBase in ASP.NET?如何在 ASP.NET 中获取对非默认 ProfileBase 的引用?
【发布时间】:2009-07-03 13:45:02
【问题描述】:

我知道我可以使用如下代码获得对 ASP.NET 中默认配置文件的引用:

ProfileBase p = ProfileBase.Create(username);

(我知道还有HttpContext.Current.Profile,但那是给当前用户的,我需要通过用户名获取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 对象模型不同,我无法弄清楚。感谢您的帮助!

罗杰·马丁

Gallery Server Pro

【问题讨论】:

    标签: asp.net profile


    【解决方案1】:

    在 .net 框架中使用 ProfileManager 类

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-01
      相关资源
      最近更新 更多