在现有成员资格方法中添加一些字段
Adding some fields in existing membership method
如何使用现有的创建用户或类似方法在 asp.net 成员资格中添加产品 ID。需要这样的会员资格>>
Membership.CreateUser(用户名,密码,产品id(需要添加方法))
Roles.AddUserToRole(Username, "some roles")
Samemethod.add(username, productid)[ addition for adding the product it ]
Need following thing with membership like that >>
Membership.CreateUser(Username, Password , Product id ( need a method
to add it ))
答案是你不能。 成员资格基于 提供商模型。您不能 add/remove 成员资格方法的参数。
此外,您不能 add/remove 会员表格的列。看看this answer.
变通
您需要使用Membership.CreateUser方法创建用户。然后使用新插入的userId添加productId.
MembershipCreateStatus status;
MembershipUser membershipUser = Membership.CreateUser("Username",
"Password", "Email", "PasswordQuestion",
"PasswordAnswer", IsApproved, out status);
if (status == MembershipCreateStatus.Success)
{
Guid userId = (Guid)membershipUser.ProviderUserKey;
// Insert product id here.
}
仅供参考: 会员提供程序几年前已被弃用。如果您正在开发新应用程序,您可能需要查看新的 ASP.Net Identity 2.
如何使用现有的创建用户或类似方法在 asp.net 成员资格中添加产品 ID。需要这样的会员资格>>
Membership.CreateUser(用户名,密码,产品id(需要添加方法))
Roles.AddUserToRole(Username, "some roles")
Samemethod.add(username, productid)[ addition for adding the product it ]
Need following thing with membership like that >>
Membership.CreateUser(Username, Password , Product id ( need a method to add it ))
答案是你不能。 成员资格基于 提供商模型。您不能 add/remove 成员资格方法的参数。
此外,您不能 add/remove 会员表格的列。看看this answer.
变通
您需要使用Membership.CreateUser方法创建用户。然后使用新插入的userId添加productId.
MembershipCreateStatus status;
MembershipUser membershipUser = Membership.CreateUser("Username",
"Password", "Email", "PasswordQuestion",
"PasswordAnswer", IsApproved, out status);
if (status == MembershipCreateStatus.Success)
{
Guid userId = (Guid)membershipUser.ProviderUserKey;
// Insert product id here.
}
仅供参考: 会员提供程序几年前已被弃用。如果您正在开发新应用程序,您可能需要查看新的 ASP.Net Identity 2.