This is a migrated thread and some comments may be shown as answers.

How to save per user/machine?

3 Answers 80 Views
Persistence Framework
This is a migrated thread and some comments may be shown as answers.
John Reynolds
Top achievements
Rank 1
John Reynolds asked on 15 Mar 2013, 03:28 AM
We've been using the GridSettingsPersister provided in the help here.
What must be done to save the settings per user or per machine in a similar fashion with the new persistence framework?

Regards,

John

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 20 Mar 2013, 11:26 AM
Hi John,

Find attached a sample application which demonstrates possible approach for achieving the required functionality.

I hope this helps.

Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Vasssek
Top achievements
Rank 1
answered on 14 Apr 2013, 08:12 PM
Hello,

FYI, in your example there isn't used the Expires property, that's why a cookie persists only during session. That means, when user closes browser and start app again, the cookie is lost.

If you want to have cookie persisted, just add line marked bold:
public void SaveStateToStorage(string key, string serializedState)
    {
        HttpCookie cookie = new HttpCookie(StorageKey);
        cookie.Expires = DateTime.Now.AddYears(1);
        string settingsData = CompressString(serializedState);
 
        if (settingsData.Length > MaxCookieSize)
        {
            throw new ArgumentOutOfRangeException("Current settings exceed 4k in compressed form! Operation canceled!");
        }
 
        cookie.Value = settingsData;
 
        HttpContext.Current.Response.Cookies.Add(cookie);
    }

Best regards

Vasssek
0
Maria Ilieva
Telerik team
answered on 16 Apr 2013, 02:04 PM
Hi Vaclav,

Thank you for pointing this. I'm sure it will be of a big help for the other users trying to implement similar scenarios.


Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Persistence Framework
Asked by
John Reynolds
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Vasssek
Top achievements
Rank 1
Share this question
or