How to delete a SimpleMembership user?

后端 未结 5 1711
野的像风
野的像风 2020-12-28 21:25

In my ASP.NET MVC app using Forms Authentication (via SimpleMembership), how do I delete a user/account?

The WebSecurity class doesn\'t expose DeleteUser. On a lark

5条回答
  •  盖世英雄少女心
    2020-12-28 21:50

    What happens if you just do Membership.DeleteUser(username,true). You might get a little prompt for adding a using directive on Membership. If you have it configured properly, you shouldn't need to be creating new SimpleMembershipProvider instance.

    If you create it on the fly like that, you'll need to set connections on that object and configure it programmatically(it has no clue about the connection you created above). Usually people do that in web.config, but if you created the app using the forms authentication template, then you should have that taken care of automatically.

    Your provider my have this bug for which is discussed and solved here: Membership.DeleteUser is not deleting all related rows of the user

提交回复
热议问题