3
我創建了自己的數據庫模式來存儲用戶信息。Extend Membership API,MembershipUser
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)
然後我擴展MembershipProvider和MembershipUser並創建重寫方法。 當我調用CreateUser方法時,如何傳遞附加信息?我知道我可以使用此配置文件,但我也希望能夠這樣做,如果它變得太複雜,我會去個人資料路線。
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;
}
}