如何删除websecurity创建的用户

时间:2013-06-23 11:11:07

标签: c# asp.net-mvc-4

我使用WebSecurity创建用户的帐户。

var confirmationToken = WebSecurity.CreateUserAndAccount(model.Username, model.Password, 
                    new { Email = model.Email,
                        Lastname = model.Lastname,
                        Firstname = model.Firstname,
                        Birthday = model.Birthday,
                        Job = model.Job,
                        City = model.City,
                        Gender = model.Gender,
                        PictureFilename = "anonyme.png"
                }, true);

但我该如何删除用户?

1 个答案:

答案 0 :(得分:10)

((SimpleMembershipProvider)Membership.Provider).DeleteAccount(userName); // deletes record from webpages_Membership table
((SimpleMembershipProvider)Membership.Provider).DeleteUser(userName, true); // deletes record from UserProfile table