ASP.Net 2.0 Profile Gotcha — duplicate users

Had a bit of a brain dump that lead to way longer than I would’ve liked debugging, and I wanted to pass it on.  I was working on an admin page for user profiles and kept getting a new user created every time I tried to edit a profile.  After much wailing and gnashing of teeth I ended up finding that I’d set up my membership and roles providers earlier, and just now got to setting up the profile provider.  Well, as luck would have it I managed to *not* set the applciationName in the profile provider, where I *did* set it in the membership and roles providers.  I also had anonymous profiles enabled…   So, every time I tried to persist a profile element (or elements), the application would create a new anonymous user in a different application than my other users were in, but it would look to me like I was duplicating users b/c I was telling the app to create a profile for the user w/ the same name as the currently logged in User in the event that said User dind’t already have one.  Clear as mud?  Well, in any event, the Gotcha is that when you tell the Profile provider to create a profile for someone, it’ll also happily create a User object for that person if a User by that name doesn’t already exist, with no warning.  Nice feature, huh?  🙂

Leave a comment