本文整理汇总了C#中System.Web.Security.MembershipProvider.DeleteUser方法的典型用法代码示例。如果您正苦于以下问题:C# MembershipProvider.DeleteUser方法的具体用法?C# MembershipProvider.DeleteUser怎么用?C# MembershipProvider.DeleteUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Security.MembershipProvider
的用法示例。
在下文中一共展示了MembershipProvider.DeleteUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DeleteUser
public void DeleteUser()
{
CreateUserWithHashedPassword();
Assert.IsTrue(provider.DeleteUser("foo", true));
var count = _db.GetCollection<User>(provider.CollectionName).Count();
Assert.AreEqual(0, count);
provider = new MembershipProvider();
CreateUserWithHashedPassword();
// in Mongo, all associated data is stored in same document so
// passing true or false to DeleteUser will be the same.
Assert.IsTrue(provider.DeleteUser("foo", deleteAllRelatedData: true));
count = _db.GetCollection<User>(provider.CollectionName).Count();
Assert.AreEqual(0, count);
//Assert.IsTrue(Membership.DeleteUser("foo", false));
//table = FillTable("SELECT * FROM my_aspnet_Membership");
//Assert.AreEqual(0, table.Rows.Count);
//table = FillTable("SELECT * FROM my_aspnet_Users");
//Assert.AreEqual(1, table.Rows.Count);
}
示例2: CreateUserAccount
public static string CreateUserAccount(MembershipProvider userMembershipProvider, User user)
{
string error = "";
user.Email = user.Email.ToLower();
User validateUser = UserService.GetUserByUsername(user.Username);
if (validateUser.UserID > 0)
return UserMessages.UsernameAlreadyUsed;
validateUser = UserService.GetUserByEmail(user.Email);
if (validateUser.UserID > 0)
return UserMessages.EmailAlreadyUsed;
MembershipCreateStatus status;
MembershipUser mu = userMembershipProvider.CreateUser(user.Email, user.Password, user.Email, null, null, true, null, out status);
if (status != MembershipCreateStatus.Success)
return UserMessages.ErrorCreatingAccount;
user.AspnetUserID = (Guid)mu.ProviderUserKey;
int userID = CreateUserAccount(user);
if(userID == 0)
{
// Delete user account
userMembershipProvider.DeleteUser(user.Email, true);
return UserMessages.ErrorCreatingAccount;
}
user.UserID = userID;
return error;
}