ASP.NET 会员资格。它可以扩展吗?
我将属性“WebSite”添加为注册用户的属性。
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="membershipSampleApp" type="System.Web.Profile.SqlProfileProvider"/>
</providers>
<properties>
<add name="Website"/>
</properties>
</profile>
该自定义属性存储在 ASPNETDB 数据库中的位置,我可以对其进行查询,例如查找共享自定义属性的相同值的所有用户吗?
如果我想要这种功能,我是否最好用我自己的并行表来扩充 USERS 表,并以 UserName 作为键连接这两个表?
I add the Property "WebSite" as a property of a registered user.
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="membershipSampleApp" type="System.Web.Profile.SqlProfileProvider"/>
</providers>
<properties>
<add name="Website"/>
</properties>
</profile>
Where is that custom property stored in the ASPNETDB database and can I query it to, for example, find all of the users that share the same value of a custom property?
If I want this sort of capability, would I be better off to augment the USERS table with my own parallel table and join the two on UserName as the key?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您可以延长会员资格。这是长篇文章解释了如何做到这一点。简而言之,
为了将值存储在数据库中,它描述了:
Yes, you can extend Membership. Here's a long article that explains how to do it. In a nutshell,
For storing the values in the database, it describes a:
我不确定您如何使用配置文件的“网站”属性,但如果您有多个网站使用同一会员存储,您最好为每个网站指定不同的应用程序名称,这就是多个网站可以使用的方式同一个会员店。
如果“网站”只是用户的一个属性,请务必将其存储在配置文件中。它并不真正保证会员资格提供者的重写。
此外,“Website”属性将存储在 aspnet_Profiles 表中(作为二进制和 XML),但这可能很难查询。使用一个以纯 SQL 格式存储属性的自定义配置文件提供程序可能更有意义。
I'm not sure how you're using the "Website" property of the profile but if you have multiple websites using the same Membership store you'd be better off specifying different application names for each site, this was how multiple webs could use the same membership store.
If "Website" is just a property for the user by all means store it in the profile. It doesn't really warrant a rewrite of the membership provider.
Also, the "Website" property would be stored in the aspnet_Profiles table (as binary and XML), this can be difficult to query though. It might make more sense to have a custom profile provider that stores the properties in plain SQL format.
默认配置文件实现牺牲了可发现性以实现易用性和灵活性。
如果您想向用户添加可索引和可查询的元数据,我建议不要扩展成员资格提供程序,因为这不是它们的用途。
一个优秀且易于实施的解决方案是使用基于表的配置文件提供程序。
请参阅 http://weblogs.asp.net/scottgu/archive /2006/01/10/435038.aspx
The default profiles implementation sacrifices discoverability for ease of use and flexibility.
If you would like to add indexable and queryable meta data to a user, I would recommend against extending the membership provider as that is not what they are for.
An excellent and easily implemented solution is to use a table based profile provider.
see http://weblogs.asp.net/scottgu/archive/2006/01/10/435038.aspx