Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove an account created by WebSecurity.CreateUserAndAccount?

Today I noticed that new MVC projects in VS 2012 are using WebMatrix.WebData.WebSecurity to handle membership related tasks.

I went to msdn to a quick look at the documentation and was surprised. Lot's of good stuff in there and it will definitely save me a lot of time in future projects.

But one thing got my attention: It doesn't have a function to "Remove Accounts". Is there a particular reason for that? Should I use the underlying membership provider to remove accounts (and other things such as unlock accounts)?

like image 642
CodeMaster2008 Avatar asked Aug 19 '12 03:08

CodeMaster2008


1 Answers

        ((SimpleMembershipProvider)Membership.Provider).DeleteAccount("username");
        ((SimpleMembershipProvider)Membership.Provider).DeleteUser("username", true);
like image 114
Tomasz Leszczynski Avatar answered Oct 03 '22 11:10

Tomasz Leszczynski