This document is archived and information here might be outdated. Recommended version. |
Save an object in the server context to a string.
[Visual Basic .NET]
Public Function SaveObject ( _
ByVal obj As Object _
) As String
[C#]
public string SaveObject (
object obj
);
[C++]
HRESULT SaveObject(
LPUNKNOWN obj
);
[C++] Parameters obj [in]
obj is a parameter of type IUnknown
These methods allow you to serialize objects in the server context to strings, then deserialize them back into objects. Any object that supports IPersistStream can be saved and loaded using these methods. These methods allow you to copy objects between contexts. For example, if you use a GeocodeServer object to locate an address, then you want to draw the point that GeocodeAddress returns on your map, you need to copy the point into your MapServer's context.
Another important use of these methods is to manage state in your application while making statless use of pooled server object. A good example of this is in a mapping application. The initial session state for all users is the same and is equal to the map descriptor for the map server object. Each user can then change map descriptor properties such as the extent and layer visibility, which need to be maintained in the users session state. The application does this by saving a serialized map descriptor as part of each users session state. Using the serialized string representation allows the application to take advantage of the standard session state management facilities of the web server. The application uses the LoadObject and SaveObject methods to reconstitute the sessions map descriptor whenever it needs to make edits to it in response to user changes or whenever it needs to pass the map descriptor to the map server object for drawing the map according to the users specifications.
It's important to note that if you are building a web application using the ESRI web controls, the controls take care of saving and loading the MapDescription for you.