How to extend aspnet membership forms authentication tables?
Asked Answered
W

2

6

I would like to add a realName field in addition to the user's user name and email address.

In the past I have created a new table that includes the username and realName columns when a user registers. However I would like to know if it is possible to extend the default asp.net forms authentication membership table or user table (or whatever table is necessary, to add this to) instead of creating a new table for this information.

Question: How can i add a new column to authentication tables?

Wong answered 5/7, 2012 at 12:41 Comment(0)
D
9

You should use the Membership User Profile API to extend custom properties to your users, and not directly add columns to the aspnet_Membership and aspnet_Users tables.

You can also look at the SqlTableProfileProvider

And make sure you read Joel's and Colivier's posts here on how to create strongly typed profile classes.

Despatch answered 5/7, 2012 at 12:45 Comment(2)
what is the bad side of adding columns directly nonnb?Novah
@Novah - hindsight has taught me not to interfere directly with guts of frameworks, for fear of breaking something. In any event, the columns won't be added to the MembershipUser class, so you will still need to add code to retrieve these fields, in which case you may as well add a separate custom user extension table keyed on the same UserId GUID.Despatch
T
1

If this is a Web Application project you will need to use a custom profile class as Profiles only come out of the box with the Website model:

http://www.codersbarn.com/post/2008/07/10/ASPNET-PayPal-Subscriptions-IPN.aspx

http://weblogs.asp.net/joewrobel/archive/2008/02/03/web-profile-builder-for-web-application-projects.aspx

Teaser answered 5/7, 2012 at 13:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.