The only method I've found is to keep track of which layers are visible at a given "scale" (ESRI deprecates that term nowadays) and provide those IDs with the "all" option each time I make an identify request. It takes a bit of logic to sort through the layers, I'm afraid.
Check out the table of contents at the silverlight code gallery for an example of maintaining visibility info. You can use REST calls to grab the min and max scales for each layer, but that's pretty chatty. To keep things simpler, what I ended up doing was create a WCF service to get all the layer info with one SOAP call: if you add a web reference to the map service in your ASP project it automatically builds the methods and data structures for you.
Error {System.Net.WebException: The remote server returned an error: NotFound. ---> System.Net.WebException: The remote server returned an error: NotFound.
at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult)
at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState)
at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState)
--- End of inner exception stack trace ---
at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state)
at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)} System.Exception {System.Net.WebException}
void QueryTask_Failed(object sender, TaskFailedEventArgs e) { if (e.Error is ServiceException) { StringBuilder sb = new StringBuilder(); foreach(string detail in (e.Error as ServiceException).Details) sb.Append(string.Format("{0}\n", detail)); MessageBox.Show(string.Format("Error: {0}", sb.ToString())); } }
Server Error - Index was outside the bounds of the array
tolerance 2
returnGeometry true
mapExtent 3219613.08846863,1726402.76275839,3226995.61041765,1732899.38207353
layers top:6
imageDisplay 1175,825,96
geometryType esriGeometryPolygon
geometry {"spatialReference":{"wkid":2232},"rings":[[[3219613.08846863,1732899.38207353],[3226995.61041765,1732899.38207353],[3226995.61041765,1726402.76275839],[3219613.08846863,1726402.76275839],[3219613.08846863,1732899.38207353]]]}
f json
Server Error - Index was outside the bounds of the array.
Code: 500