Adding custom properties to MembershipUser, what are the options ?

Last post 08-16-2009 4:49 AM by anas. 0 replies.

Sort Posts:

  • Adding custom properties to MembershipUser, what are the options ?

    08-16-2009, 4:49 AM
    • All-Star
      59,468 point All-Star
    • anas
    • Member since 09-21-2006, 8:31 AM
    • Palestinian Territory, Occupied
    • Posts 6,739
    • Moderator

    One of a frequently asked questions is “how to add a custom columns/properties to the MembershipUser class?”.

    Based on my experience , there are many ways to do that :

    1. You can use the user profile services to store those custom properties, article [here].
    2. Create a custom database table with a 1-1 relationship with the membership users table and handle the read/write operations on that custom table using ADO.NET or any other data access technology, article [here]
    3. Create a custom MembershipUser that inherits the MembershipUser class and add the new properties.articles [here] and video.

    But which method is the best for you ?

    every method has proc/cons , i will list them all in the table below:

    Storage method Pros Cons
    User’s profile Doesn’t require any additional code, just you need to declare the custom properties in web.config and you can then use the Profile class to read/write or manipulate these values not suitable if you are going to display the user information via an external reporting tool like Reporting services.This is because the Profile services will store the data in a serialized format.
    Custom database table Very flexible and can be displayed using any external reporting tool. Needs more work to handle the data access code and write some helper classes to manipulate the custom user properties.
    Custom MembershipUser and MembershipProvider Cleaner,maintainable and flexible solution.Also integrates with the current Login controls. 
    It needs more more effort because it will requires to write custom membershipUser and MembershipProvider …
    Regards,

    Anas Ghanem | Blog

Page 1 of 1 (1 items)