2 votes
WebProfile.Current should not be a singleton


The optimization you did for release 1.2.0 basically made the WebProfile.Current property a singleton pattern. Whomever's profile is accessed first through the WebProfile.Current property, is subsequently used in all user sessions. Lose the static WebProfile _current; caching and you'll fix the problem. It's un-usable as-is.

To see this problem, I have a website using forms authentication and profiling enabled. In one of my pages I store the user's preference for number of rows displayed on a grid. The default is 20. I login using IE as User1 and change my profile default from 20 to 10 and the grid responds by displaying only 10 rows. I now login using FireFox (so I can login as a different user simultaneously) as User2. I navigate to the page with the grid. I am expecting to see the default value of 20 rows displayed but I get only 10. As User2 I change the default to 100. Then switch to the IE browser where I'm logged in as User1. I refresh the page and the grid now displays 100 rows. Both (different) user sessions are accessing the same user profile through the WebProfile.Current property.

File Attachments

No files are attached

Closed May 5 2008 at 7:54 AM  by robolize
Fixed in version 1.3.


most recent at top (show oldest at top)
GotzBoost wrote Jan 10 2009 at 10:48 AM
Just thought about using the cache, if you do so be sure to store it with users id/username as the key. Cache is also shared among sessions.

GotzBoost wrote Jan 10 2009 at 10:45 AM
Incorrect, it needs to be a singleton; it just needs to be fixed for web usage. In a normal app this would work fine, but I forget that a static object in a web app is shared among all sessions because they are the same app. Do not revert back, let’s just fix this. Get rid of the static object and store it in the Cache, session state, or some other consistent state.

Otherwise you will just be creating new objects upon each call, wasting cpu and memory.


robolize wrote May 5 2008 at 6:22 AM
Good call. What can I say other than I screwed up. I will revert this change for version 1.3. Thanks for your feedback and patients.

Page view tracker