private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here if (Session.IsNewSession) { //get default mapcontrol model from session MapInfo.WebControls.MapControlModel controlModel = MapControlModel.SetDefaultModelInSession(); //add custom commands to map control model controlModel.Commands.Add(new CreateTheme()); controlModel.Commands.Add(new RemoveTheme()); controlModel.Commands.Add(new GetLegend()); //instanciate AppStateManager class AppStateManager myStateManager = new AppStateManager(); //put current map alias to state manager dictionary myStateManager.ParamsDictionary[StateManager.ActiveMapAliasKey] = this.MapControl1.MapAlias; //put state manager to session StateManager.PutStateManagerInSession(myStateManager); } // Now Restore State StateManager.GetStateManagerFromSession().RestoreState(); }