Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persisting user preferences in Silverlight

I am working on a Silverlight client and associated ASP.NET web services (not WCF), and I need to implement some features containing user preferences such as a "favourite items" system and whether they'd like word-wrapping or not. In order to make a pleasant (rather than infuriating) user experience, I want to persist these settings across sessions. A brief investigation suggests that there are two main possibilities.

  1. Silverlight isolated storage
  2. ASP.NET-accessible database

I realise that option 2 is probably the best option as it ensures that even if a user disables isolated storage for Silverlight, their preferences still persist, but I would like to avoid the burden of maintaining a database at this time, and I like the idea that the preferences are available for loading and editing even when server connectivity is unavailable. However, I am open to reasoned arguments why it might be preferrable to take this hit now rather than later.

What I am looking for is suggestions on the best way to implement settings persistence, in either scenario. For example, if isolated storage is used, should I use an XML format, or some other file layout for persisting the settings; if the database approach is used, do I have to design a settings table or is there a built-in mechanism in ASP.NET to support this, and how do I serve the preferences to the client?

So:

Which solution is the better solution for user preference persistence? How might settings be persisted in that solution, and how might the client access and update them?

Prior Research

Note that I have conducted a little prior research on the matter and found the following links, which seem to advocate either solution depending on which article you read.

  • http://www.ddj.com/windows/208300036
  • http://tinesware.blogspot.com/2008/12/persisting-user-settings-in-silverlight.html

Update

It turns out that Microsoft have provided settings persistence in isolated storage as a built-in part of Silverlight (I somehow missed it until after implementing an alternative). My answer below has more details on this.

I'm keeping the question open as even though Microsoft provides client-side settings persistence, it doesn't necessarily mean this is the best approach for persisting user preferences and I'd like to canvas more opinions and suggestions on this.

like image 684
Jeff Yates Avatar asked May 05 '09 19:05

Jeff Yates


1 Answers

After investigating some more and implementing my own XML file-based settings persistence using IsolatedStorage, I discovered the IsolatedStorageSettings class and the IsolatedStorageSettings.ApplicationSettings object that is a key/value collection specifically for storing user-specific, application settings.

It all seems obvious now. Of course, in the long term, a mechanism for backing up and restoring settings using a server database would be a good enhancement to this client-side settings persistence.

like image 154
Jeff Yates Avatar answered Sep 21 '22 17:09

Jeff Yates