Extend Membership API, MembershipUser

折月煮酒 提交于 2019-12-21 05:49:23

问题


I created my own database schema to store user information.

CREATE TABLE [dbo].[MyCustomMembership_Users](
[UserId] [uniqueidentifier] NOT NULL,
[UserName] [nvarchar](256) NOT NULL,
[LoweredUserName] [nvarchar](256) NOT NULL,
[MobileAlias] [nvarchar](16) NULL,
[IsAnonymous] [bit] NOT NULL,
[LastActivityDate] [datetime] NOT NULL,
[FirstName] [nvarchar](256) NULL,
[MiddleName] [nvarchar](256) NULL,
[LastName] [nvarchar](256) NULL)

Then I extend the MembershipProvider and MembershipUser and create the overriden methods. How can I pass the additional information when I call the CreateUser Method? I am aware I can use profile for this but I also want to be able to do it this way and if it comes out to be too complicated that I will go the profile route.

public class MyMembershipProvider : MembershipProvider
{
  public override MembershipUser CreateUser(string username, string password, 
string email, string passwordQuestion, string passwordAnswer, bool isApproved, 
object providerUserKey, out MembershipCreateStatus status)
    {
        throw new NotImplementedException();
    }
}
public class MyMembershipUser : 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 MyMembershipUser() : base()
    {
        this.FirstName = _firstName;
        this.MiddleName = _middleName;
        this.LastName = _lastName;
    }
}

回答1:


You could pass a MyMembershipUser in the providerUserKey object



来源:https://stackoverflow.com/questions/538059/extend-membership-api-membershipuser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!