# Why do Web ADF Map and MapResourceManager maintain their state in session this way?

I'm using ArcGIS Server Local datasource. ArcGIS Web ADF MapResourceManager control maintains resources added once until session is abandoned. Why does it do so? Why not just use viewstate? Map control maintains it's state in session, too (and Toc).

The minor problem is that before adding a new MapResourceItem to MapResourceManager I have to check wether it's inside already (with normal controls I would just check for Page.IsPostBack). The major one - how am I exposed to clear map's and toc's state (other that read default values and set them, overwriting whatever it saved into it's state; extent for example). I tried to call RefreshServerObjects() on MapResourceLocal, call GetStateFromDataSourceObjects() on IMapFunctionality retrieved from Map control. The only way that works is HttpContext.Current.Session.Abandon() which is not a solution.

So how do you either turn off storing map state in session or how do you reset that state at any time?

EDIT:

Just found a way to clear just map's session state without abandoning whole session: map.StateManager.RemoveAllSessionState(false);

But the question is still up - why is it done this way?

-