Search code examples
asp.net-mvcasp.net-membership

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)?


Solution

  • Found the answer at MSDN: http://msdn.microsoft.com/en-us/library/webmatrix.webdata.simplemembershipprovider%28v=vs.111%29

    In ASP.NET Web Pages sites, you can access the functionality of the SimpleMembershipProvider class by using the Membership property of a web page. You do not (in fact, cannot) initialize a new instance of the SimpleMembershipProvider class...