How to: Save a Dashboard State to Cookies and Restore this State on the Server Side (MVC)

  • 3 minutes to read

The sample illustrates how to save the current ASP.NET MVC Dashboard state (such as master filter or parameter values) to cookies on the client side and restore this state on the server side. The following API is used in this example:

using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using System.Web;
using System.Xml.Linq;

namespace MvcDashboard_DashboardStateCookies {
    internal class CustomDashboardStateService : IDashboardStateService {
        public DashboardState GetState(string dashboardId, XDocument dashboard) {
            HttpCookie cookie = HttpContext.Current.Request.Cookies["MVCxDashboardState"];
            if (cookie != null) {
                DashboardState dashboardState = new DashboardState();
                return dashboardState;
                return null;