Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 226761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:32:32+00:00 2026-05-11T19:32:32+00:00

I am going round in circles and need some help in implementing a Custom

  • 0

I am going round in circles and need some help in implementing a Custom MembershipUser so that I can add my own custom Properties to the MembershipUser.

I have been following the example on this site: How to: Implement a Custom Membership User

The problem I am having is in the constructor of CustomMembershipUser, I think.

My CustomMembershipUser has these three additional Properties: firstName, middleName, lastName.

public class CustomMembershipProvider : MembershipProvider
{
  public override MembershipUser GetUser(string username, bool userIsOnline)
    {
       //.... Get data from database
       MembershipUser baseUser = new MembershipUser(this.Name,
                                               username,
                                               userId,
                                               email,
                                               "",
                                               comment,
                                               isApproved,
                                               isLockedOut,
                                               dtCreate,
                                               dtLastLogin,
                                               dtLastActivity,
                                               DateTime.Now,
                                               dtLastLockoutDate);
                    return new CustomMembershipUser(baseUser, firstName, middleName, lastName)
    }
}


public class CustomMembershipUser : MembershipUser
{
  private string _firstName;
    public string FirstName { get { return _firstName; } set { _firstName = value; } }

    private string _middleName;
    public string MiddleName { get { return _middleName; } set { _middleName = value; } }

    private string _lastName;
    public string LastName { get { return _lastName; } set { _lastName = value; } }

 public CustomMembershipUser(MembershipUser baseuser, string firstname, string middlename, string lastname)
    {
        _firstName = firstname;
        _middleName = middlename;
        _lastName = lastname;

        new CustomMembershipUser(baseuser); // DO I NEED THIS?? HOW TO IMPLEMENT??
        
    }
}

I am calling it like so:

    MembershipUser mu = Membership.GetUser(UserName);

    CustomMembershipProvider p = (CustomMembershipProvider)Membership.Provider;
    
    MembershipUser memUser = p.GetUser(UserName, true);

    object userId = memUser.ProviderUserKey;

The ProviderUserKey is null and so are the other values.

How can I obtain the addition Properties I added?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:32:32+00:00Added an answer on May 11, 2026 at 7:32 pm

    This is working for me:

    public class CustomMembershipUser : MembershipUser
    {
        public CustomMembershipUser(
            string providerName,
            string name,
            object providerUserKey,
            string email,
            string passwordQuestion,
            string comment,
            bool isApproved,
            bool isLockedOut,
            DateTime creationDate,
            DateTime lastLoginDate,
            DateTime lastActivityDate,
            DateTime lastPasswordChangedDate,
            DateTime lastLockoutDate
            )
            : base(providerName, name, providerUserKey, email, passwordQuestion,
            comment, isApproved, isLockedOut, creationDate, lastLoginDate,
            lastActivityDate, lastPasswordChangedDate, lastLockoutDate)
        {
        }
    
        // Add additional properties
        public string CustomerNumber { get; set; }
    
    }
    
    public class CustomMembershipProvider : MembershipProvider
    {
    
        public override MembershipUser GetUser(string username, bool userIsOnline)
        {
            if (string.IsNullOrEmpty(username))
            {
                // No user signed in
                return null;
            }
    
            // ...get data from db
    
            CustomMembershipUser user = new CustomMembershipUser(
                        "CustomMembershipProvider",
                        db.Username,
                        db.UserId,
                        db.Email,
                        "",
                        "",
                        true,
                        false,
                        db.CreatedAt,
                        DateTime.MinValue,
                        DateTime.MinValue,
                        DateTime.MinValue,
                        DateTime.MinValue);
    
            // Fill additional properties
            user.CustomerNumber = db.CustomerNumber;
    
            return user;
    
        }
    
    }
    
    // Get custom user (if allready logged in)
    CustomMembershipUser user = Membership.GetUser(true) as CustomMembershipUser;
    
    // Access custom property
    user.CustomerNumber
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use System.Threading.Timer, it will run a task in a ThreadPoool… May 12, 2026 at 12:00 am
  • Editorial Team
    Editorial Team added an answer According to Microsoft it's 2048. Since they invented the internet… May 12, 2026 at 12:00 am
  • Editorial Team
    Editorial Team added an answer Might be a case for RAII! Dun-dun-dunnn! struct f1 {… May 12, 2026 at 12:00 am

Related Questions

I realize there have already been a number of posts on n-tier design and
I am trying to find a good way of accessing a Business Intelligence OLAP
I have an app where I want to link an instance of a model
I am building a plugin for a LAN party website that I wrote that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.