Pitney Bowes MapXtreme User Manual

Page 114

Advertising
background image

Chapter 6: Understanding State Management

State Management For Pooled Objects

MapXtreme v7.1

114

Developer Guide

9. The application modifies the Map object's Zoom property so that it is zoomed into Australia. The

application renders a new map image and streams the image to the client browser. Again, the
application saves the user's state at the end of the request.

10. The user clicks on the Select tool, and then clicks on the Australia region of the map, to select

Australia.

11. The application again fetches a MapXtreme Session from the pool, and again calls RestoreState

to set the pooled object to a known state.

12. On the server, the application carries out the operation to select Australia. A new map image is

rendered, to display the new selection.

13. On the server, the application again calls AppStateManager.SaveState, to save the user state.

Since this example allows the user to perform selections, the AppStateManager's SaveState and
RestoreState methods will need to include code to save and restore Selections.
Any aspect of the MapXtreme session that you allow a user to change, such as layers, themes,
queries, map views, must be handled in your code to save and restore each item.

Using pooling and managing user state manually is beneficial in that it improves efficiency and
allows applications to be scalable. However, this model does require additional work, in terms of
saving the user state at the end of each request, and then restoring that state at the beginning of that
user's next request.

Configuring a Pooled Application to Use Manual State Management

For examples of a pool application using manual state management, see the sample web
applications that ship with MapXtreme. The following are the main points for configuring such an
application.

Configure pooled objects in the Web.Config file using the settings:

<!--Use this setting to turn Session pooling on/off (true/false)-->
<add key="MapInfo.Engine.Session.Pooled" value="true" />
<!--Use this setting to save Session state automatically
(HttpSessionState) or manually (Manual)-->
<add key="MapInfo.Engine.Session.State" value="Manual" />
<sessionState mode="StateServer" stateConnectionString=
"tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;user
id=sa;password=" cookieless="false" timeout="20" />

These two settings can be combined into the following options:

For pooled objects and automatic state management, set Pooled to true, and set State to
HttpSessionState.

For pooled objects and manual state management, set Pooled to true, and set State to Manual.

Place the logic that determines the user’s current state into the Page_Load method. See

Implementing a StateManager on page 122

.

Advertising