Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8639415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:59:53+00:00 2026-06-12T10:59:53+00:00

I’m missing a concept here. I was assuming that Membership.DeleteUser() would expunge a user

  • 0

I’m missing a concept here. I was assuming that Membership.DeleteUser() would expunge a user from my membership tables. My code:

// remove all but 'admin' from Membership
MembershipUserCollection users = Membership.GetAllUsers();

foreach ( MembershipUser user in users )
{
    if ( user.UserName != "admin" )
    {
        Membership.DeleteUser( user.UserName );
    }
}

DeleteUser() fails with exception:

The DELETE statement conflicted with the REFERENCE constraint 
"FK__aspnet_Me__UserI__58D1301D". The conflict occurred in database 
"MyDatabase", table "dbo.aspnet_Membership", column 'UserId'.
The statement has been terminated.

In my Web.config:

<membership defaultProvider="MyMembershipProvider">
  <providers>
    <clear/>
    <add name="MyMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MembershipConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="MyApplication"/>
  </providers>
</membership>

I get it that there’s a foreign key relationship between Membership.UserId -> Users.UserId but would have assumed that the whole point of DeleteUser() is to remove all the records for this user in the Membership, User and UsersInRoles tables, to name a few.

Of course, I could go straight into the Membership table and delete the appropriate record, but that’s defeating the purpose of using the API. What am I doing wrong? What is the correct way to delete a user from the Membership tables?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T10:59:54+00:00Added an answer on June 12, 2026 at 10:59 am

    Well, Membership.DeleteUser(string) calls SqlMembershipProvider.DeleteUser(string, bool) with true, and that calls the stored proc aspnet_Users_DeleteUser. That sproc has code in it to delete the various extra data in other tables that are related.

    You can check your sproc to see if it’s been altered.

    The only other thing I can think of is whether or not you created any other foreign key relationships to the Membership tables, such as to your own users table? If so, you would have to delete those records first. This is one reason it’s not recommended to create such foreign key relationships.

    Check the FK relationships on the aspnet_Membership table and see if there are any that shouldn’t be there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.