.NET ADF WebMapProblem Part 1
Not sure if any of you guys have been playing or havnig lots of problems with the WebMap class on the .NET ADF?
Here are few of a senarios I have come up with:
1. Using The Map Control
You have a map control with an impersonation control on the page.
This is great but rather simple for an ArcGIS Server implementation. The disadvantage is that having that map control on the page, means you have to hard code the impersonation string, and hard code the host and serverobject. You can try and work around this, but after all different ways of trying its not possible.
Reason?. Well the MapControl Init() gets called before the Page_Load event, which means anything in Page_Load or Pre_Render wont get called!. The MapControl also expects these properties to be set before Init() gets called else, it will crash and complain that these are blank!.
So what are your options? Well from looking at the WebMap constructor you would think you could utilise one of these, as below.
Construct a WebMap object with the specified IServerContext
public WebMap(IServerContext,string,string);
Class Constructor for use with an AGSWebControl
public WebMap(AGSWebControl,IServerContext);
Construct a WebMap object with the default dataframe and default Imageformat (PNG)
public WebMap(ServerConnection,string);
Construct a WebMap object with the specified DataFrame and default ImageFormat (PNG)
public WebMap(ServerConnection,string,string);
Construct a WebMap object with the specified DataFrame and ImageDescriptor
public WebMap(ServerConnection,string,string,ImageDescriptor);
2. Using a Constructor
Now that we have seen the constructor, we can easily enough try and use one of these.
Excellent, so lets say we have done this and we “assume” we have a webmap now?.
Well if you try and call anything in a the WebMap you will notice it fails? The error thrown? Object reference not set to an instance of an object.
Now you think to yourself, what the hell?. Well after a bit of searching and actually reverse engineering the ESRI.ArcGIS.Server.WebControls, I noticed that it suddenly needs something called a StateManager. The StateManager takes a ViewState and internally the WebMap makes use of this statemanager to “manage” state.
The funny thing is that I couldnt find this documented anywhere?. I had to reverse engineer the DLL.
Ok ok, we now have a functional WebMap created using one of the constructor’s. At first thoughts its looks all fine and we’re happy. We have a WebMap, and we have the ability to code the impersonation and server connection so we are all happy?.
Not for very long!. Something very very bad happens!!
To be continued

