views:

291

answers:

5
+2  Q: 

Asp.net membership

If I want to do an admin function like delete a user on the asp.net membership stuff that ships with the asp.net mvc sample.

I tried looking through the tables and realized that there was multiple tables that had rows added. I assume there must be a simpler way.

+2  A: 

Use the Membership API's.

To delete a user, use the Membership.DeleteUser method

Membership.DeleteUser(User.Identity.Name, true);
Jon Galloway
+6  A: 

In your Membership provider there is a method:

public bool DeleteUser(string username, bool deleteAllRelatedData)

If this is the standard asp.net membership provider that method runs a stored proc that cleans the user from your DB.

Here is some more examples: http://www.4guysfromrolla.com/articles/091207-1.aspx

BigBlondeViking
+2  A: 

Don't delete direct from the database, go through the membership provider and call the Membership.DeleteUser method.

Dan Diplo
+1  A: 

The Membership Provider base class has the methods you need. For example to delete a user you use the DeleteUser method. What you do NOT do is directly access the SQL database

blowdart
A: 

You can also use the ASP.NET Configuration Tool.

http://msdn.microsoft.com/en-us/library/ms998347.aspx - Step 3 shows how to add users. The same principle applies for deleting them. You can also mark them as inactive instead of deleting them. I usually mark them as inactive to preserve my database relationships.

Mike C.