Handling subsequent requests, A closer look at the mapxtreme session – Pitney Bowes MapXtreme User Manual

Page 121

Advertising
background image

Chapter 6: Understanding State Management

A Closer Look at the MapXtreme Session

MapXtreme v7.1

121

Developer Guide

3. Next, in the Page_Load method, we make a call to RestoreState to check whether this is the first

request for this application.
If this is the first request for the application, we call SaveDefaultState method to set various
properties on the map to their initial state and we call a ManualSerializer method, to store this
initial map state in a byte array into HttpApplicationState.
Conversely, if this a user's first request, but not the very first request for the application, we make
a call to RestoreDefaultState to reset the properties to their initial state.

Handling Subsequent Requests

After the user’s first request has been handled, he or she will likely submit additional requests, such
as clicking the map to zoom in. This time when RestoreState is called (either in the Page_Load
method or from the map tools), the initial request logic will be skipped. Instead the code that restores
the user's state is executed.

At the end of the user's session, or after using a map tool, the SaveState method is called to save
the state of the session.

L

This Page_Unload method will not get called if you use Server.Transfer or
Response.Redirect with endResponse flag as true, because those methods will ignore this
event handler. You could explicitly invoke
MapInfo.WebControls.StateManager.GetStateManagerFromSession().SaveState() before
processing Server.Transfer or Response.Redirect with endResponse flag as true to work
around this issue.

A Closer Look at the MapXtreme Session

The MapXtreme Session is the starting point for all MapXtreme applications. It manages the
initialization of resources needed for a MapXtreme application. The Session also provides access to
other important objects such as Data.Catalog, MapFactory, CoordSysFactory, Selections, and
others.

To access the MapXtreme Session, call the MapInfo.Engine.Session.Current() method. Each thread
in your process has a MapXtreme Session object available. There can be only one MapXtreme
Session per thread and this session cannot be shared by multiple threads.

Web applications can have one MapXtreme Session object per user, or pooled MapXtreme
Sessions available to many users. The following section describes the COM+ pooling options in
more detail.

Advertising