Friday, April 11, 2008

ProfileManager.DeleteProfile

I wanted to find out how would the web site behave when suddenly there is no profile for the logged in user, i.e. it was deleted from the Profile provider. It turned out that it's a bit more than simply calling the DeleteProfile method.

In one scenario this methods returns True even though in fact it's not actually deleted the user from the aspnet_Users table. This scenario is when you're trying to delete a profile while the that user is logged-in within the same browser session. Strangely, the SQL Server Profile traces seemed to confirm the deletion since the transaction as commited. (However if you dig a little deep into the stored procedure, you'll see that DELETE FROM aspnet_Users call condition is not satisfied and therefore not called.)

The trick was to delete the profile while not logged-in in the same browser. This is another reason you need both IE and FireFox for development purposes.

Here are the steps:
1. In IE, login as the user.
2. In FireFox, navigate to the page that triggers the DeleteProfile call. I supposed this could be achieved in a command line application.
3. Go back to IE and refresh the page or click to other pages.

Beware that users who are logged-in will have unexpected web site behavior, i.e. this exercise is not recommended in all server environments.

0 comments: