I'm working on an Identify tool that works against all layers in the map. The code is pretty straight forward and very similar to the ESRI samples as shown below. It works great in most cases including dynamic services with projections different than the map.Where I'm having a problem is getting the results back for a service where security has been enabled in ArcGIS Server (using windows accounts as the store & I am in a group with access to the services). When the Identity executes against one of these services I see 2 Requests being sent in Fiddler - the 1st returns a 401 not authorized error and the 2nd contains the results of the identify. I believe this double request scenario is normal as it does this if I pan the map and it makes an export image request against the service - please correct me if I am wrong though. However I never get the valid results in the ExecuteCompleted routine but the layer draws fine in the map. What am I missing with these secured services? Thanks, Terry
public void Identify(MapPoint ptMapPoint)
{
//called from btnIdentify on the toolbar - runs an Identiy on all map layers
IdentifyTask IDTask;
IdentifyParameters idParams = new IdentifyParameters()
{
Geometry = ptMapPoint,
MapExtent = _Map.Extent,
Width = (int)_Map.ActualWidth,
Height = (int)_Map.ActualHeight,
LayerOption = LayerOption.all,
SpatialReference = _Map.SpatialReference
};
for (int i = 0; i < _Map.Layers.Count; i++)
{
if (!(_Map.Layers is GraphicsLayer))
{
IDTask = new IdentifyTask();
IDTask.ExecuteCompleted += IdentifyTask_ExecuteCompleted;
IDTask.Failed += IdentifyTask_Failed;
IDTask.Url = MapUtils.GetLayerURL(_Map.Layers);
IDTask.ExecuteAsync(idParams, i);
}
}
}
private void IdentifyTask_ExecuteCompleted(Object sender, IdentifyEventArgs args)
{
//simplified for debugging...
if ((args.IdentifyResults != null) && (args.IdentifyResults.Count > 0))
{
MessageBox.Show((sender as IdentifyTask).Url + " num results= " + args.IdentifyResults.Count);
}
else
{
MessageBox.Show((sender as IdentifyTask).Url + " has no ID results");
}
}
private void IdentifyTask_Failed(Object sender, TaskFailedEventArgs e)
{
MessageBox.Show("Identify failed. Error: " + e.Error.Message);
}