Save data in http session object
- Hello,
I need my Expression blend application to store a few piece of data in a browser cookie. I am currently using VS 2008 and I thought I could use the session object to store the data so it would persist after the application is closed.
The session object is defined in the library System.web.dll. Unfortunately, when I try to reference this library I get an error stating that the library can not be added as it was not built against Silverlight runtime.
Can an expression blend app save data into a session object?
Thanks in advanced for your help,
Didier
Answers
- For anyone interested it turns out Silverlight uses a costruct called isolated storage. Below is some sample code that shows you how to store variables into this storage:
// Create an instance of IsolatedStorageSettings.
private IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;
//***************************************************************************************
// Fetch the value of the saved searches from the isolated storage
//***************************************************************************************
foreach (KeyValuePair<string,object> k in userSettings) {
// Add a SavedQuery object to the Search object
SavedQueries savedquery = new SavedQueries();
savedquery.name = k.Key;
savedquery.fql = (string)k.Value;
search.savedqueries.Add(savedquery);
}
// Add a SavedQuery object to the Search object
SavedQueries savedquery = new SavedQueries();
savedquery.name = savequerynametextbox.Text;
savedquery.fql = search.espfql;
search.savedqueries.Add(savedquery);
// Add a key and its value.
userSettings.Add(savedquery.name, savedquery.fql);- Marked As Answer byddaoliver Tuesday, November 10, 2009 11:07 PM
All Replies
- For anyone interested it turns out Silverlight uses a costruct called isolated storage. Below is some sample code that shows you how to store variables into this storage:
// Create an instance of IsolatedStorageSettings.
private IsolatedStorageSettings userSettings = IsolatedStorageSettings.ApplicationSettings;
//***************************************************************************************
// Fetch the value of the saved searches from the isolated storage
//***************************************************************************************
foreach (KeyValuePair<string,object> k in userSettings) {
// Add a SavedQuery object to the Search object
SavedQueries savedquery = new SavedQueries();
savedquery.name = k.Key;
savedquery.fql = (string)k.Value;
search.savedqueries.Add(savedquery);
}
// Add a SavedQuery object to the Search object
SavedQueries savedquery = new SavedQueries();
savedquery.name = savequerynametextbox.Text;
savedquery.fql = search.espfql;
search.savedqueries.Add(savedquery);
// Add a key and its value.
userSettings.Add(savedquery.name, savedquery.fql);- Marked As Answer byddaoliver Tuesday, November 10, 2009 11:07 PM

