How to preserve the user information in service context

This is follow up to my previous blog on things to watch out when developing application using SL3 + RIA. One issue I ran into during the testing is that the user information did not get persisted as I would have thought. One of the implementation suggested that, Use create the Authentication Service and then implement a singleton pattern to preserve the user once the validation user is successful. From there all the services can consume the singleton user. In my development everything worked great. I didn’t even think twice because each service request will run in its own application domain and so singleton will be a good solution. Well it turned out that my ‘assumption’ was wrong. It seems when two people access the same silver light page, the first user information gets the store and all following users end up using the first user identity and of course it is wrong.

To resolve that problem, I ended up removing the singleton user and started access the User information directly off of ServiceContext.User, but here is the catch. If you override the User information with your custom user and added some property to it, it is not available. But for starters, I have resolved the current problem and I will revisit to see why I can not user custom user I have created.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s