Why are map updates not reflected in .NET app when updated through ArcGIS server webmap viewer?

1324
4
Jump to solution
10-01-2019 12:27 PM
AdrianShephard
New Contributor II

I am building a desktop app in C# .NET v100.6.0.0 Runtime SDK. It pulls in maps from various sources without issue. In particular, I am using an Arc GIS server on site which hosts a variety of maps that my company uses to work on. I have the desktop app successfully authenticating, saving, and publishing maps to the server without issue.

However, whenever the map is updated through the portal web UI (like <server>/portal/home/webmap/viewer.html?webmap=xxx), the changes are not reflected in the .NET environment. After logging the map JSON in .NET, I noticed that the data is different, including basemaps, layers, versions, etc. I believe this is either the reason or an effect of what my issue is.

How is it even possible that the map returns two different JSON files when using the SAME EXACT url? To reiterate my issue plainly:

  1. Save a map using .NET application to GIS server
  2. Open map in GIS server webviewer UI and edit something (basemap, feature, etc) and save it
  3. Reload the map in .NET application, no change <- problem
    1. If I make a change in .NET application and save it, the map updates in the GIS server viewer just fine

It is insanely frustrating to reference THE SAME url and get COMPLETELY different results back depending on where I'm referencing it from. I don't know how or why this happens, but it shouldn't even work that way in the first place.

To compound the issue, if I try another computer with the .NET app, it will grab the latest "version" of the map, whether it was made in .NET or webapp, and thereafter repeat the problem - it will not retrieve updates.

I am NOT caching anything. It behaves this way in both debug and production copies/modes. I have used every way I've found to create a map (constructors, portal.createasync, etc). It is a straightforward/vanilla install of the 100.x.x SDK. Nothing is databased. All code and variables are initialized on startup. I'm out of ideas.

Thank you for your time.

0 Kudos
1 Solution

Accepted Solutions
AdrianShephard
New Contributor II

I found the issue. Well, my IT guy found the issue after playing around with my app.

IE CACHE. Apparently, when my .NET application was making a request to our GIS server on site, it goes through IE CACHE to load resources. However, it DOES NOT go through IE CACHE when requesting an online resource and retrieves the latest (like ArcOnline); hence the confusion.

To get the latest update from the server, I have to use CCleaner to wipe IE CACHE data. It then loads the most recent web map from our GIS server. This is not required for online resources. I will have to figure out a way to remove or ignore that IE CACHE data in the app. Relying on clients to set cache to off in Internet Options is not a solution.

I figured it was a caching issue, but I was assuming our server deployment was caching for performance; I ruled out the client computer as it 'felt like' more of a server side problem.

This was not due to my own code. I had the same issue from forks off of GitHub of projects directly from Esri. Maybe disabling IE CACHE is a standard and I'm an idiot for not realizing it, but it might be a good thing to have noted somewhere in SDK documentation. It drove me insane.

Client: .NET SDK 100.6.0, Esri.ArcGISRuntime.WPF, Windows 10
Server: ArcEnterprise 10.6.1 Windows

View solution in original post

0 Kudos
4 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

Sounds like you have an interesting problem...

- Can you share minimal repro code?

- Can you clarify what you mean by "Reload the map"?

- Can you clarify how you are doing this "After logging the map JSON in .NET"?

- What do you see when running Fiddler?

Thanks

Mike

0 Kudos
AdrianShephard
New Contributor II

Michael,

Thank you for the reply. I'll be linking code snips with codeshare, I don't see a way to efficiently embed code here.

The SaveMapClicked function is almost verbatim out of esri documentation (Save a map—ArcGIS Runtime SDK for .NET | ArcGIS for Developers ). It saves to the server by virtue of being authenticated, which works fine and is also nearly verbatim out of esri documentation (Authenticate with OAuth | ArcGIS for Developers )

"Reloading the map"

I simply have the web map loaded in a combo box. On selection changed, it fires the webmap selector code, which fetches a webmap id and sets mapview.Map to the map constructed from the id. This is fairly trivial. I've also hotwired the map to just initialize with the webmap id, and numerous other things to display it; nothing refreshes it from the server.

"After logging the map JSON in .NET"
In the code above, after selecting the web map, I call map.ToJson() and read the output to Debug.Write(), which matches the map displayed in the map view. However, I also log map.Uri, and when I follow that Uri to the server and look at the Json in browser, it differs in comparison to the log in .NET. 

As you can tell, a lot of this is plain vanilla, I don't have much else happening here.

I have a feeling that the server is sending back some cache'd json depending on what framework is requesting it. I don't have any objective reasoning to think that other than a hunch. Is there anything in this environment (GIS server or .NET SDK) that can cause that kind of behavior?

Again, thank you.

0 Kudos
AdrianShephard
New Contributor II

A little more info:

I just made and saved a new map in the viewer. After referencing it via webmap id:

the JSON returned in .NET:

{"baseMap":{"baseMapLayers":[{"id":"layer0","layerType":"ArcGISTiledMapServiceLayer","opacity":1,"title":"World Dark Gray Canvas Base","url":"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer","visibility":true},{"id":"World_Dark_Gray_Reference_8618","isReference":true,"layerType":"ArcGISTiledMapServiceLayer","maxScale":70.531073500000005,"minScale":591657527.591555,"opacity":1,"title":"World Dark Gray Reference","url":"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Reference/MapServer","visibility":true}],"title":"Dark Gray Canvas"},"referenceScale":0,"spatialReference":{"wkid":102100,"latestWkid":3857},"version":"2.9","authoringApp":"RuntimeSDK","authoringAppVersion":"100.6.0.2513"}

the JSON returned by referencing the URL via browser:  (like https://<server>/rest/content/items/<webmapid>/data

{"operationalLayers":[],"baseMap":{"baseMapLayers":[{"id":"layer0","layerType":"ArcGISTiledMapServiceLayer","url":"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer","visibility":true,"opacity":1,"title":"World Dark Gray Canvas Base"},{"id":"World_Dark_Gray_Reference_8618","layerType":"ArcGISTiledMapServiceLayer","url":"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Reference/MapServer","visibility":true,"opacity":1,"title":"World Dark Gray Reference","minScale":5.91657527591555E8,"maxScale":70.5310735,"isReference":true}],"title":"Dark Gray Canvas"},"spatialReference":{"wkid":102100,"latestWkid":3857},"authoringApp":"WebMapViewer","authoringAppVersion":"10.6.1","version":"2.11","referenceScale":0}

  • They are the same; however, AuthoringApp, RuntimeSDK, and authoringAppVersion is different. It matches my .NET environment locally, but why is it returning that from the server? I made it with the server web viewer, not .NET

I then updated the basemap to imagery and resaved it in the viewer. After referencing it via webmap id:

the JSON returned in .NET:

{"baseMap":{"baseMapLayers":[{"id":"layer0","layerType":"ArcGISTiledMapServiceLayer","opacity":1,"title":"World Dark Gray Canvas Base","url":"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Base/MapServer","visibility":true},{"id":"World_Dark_Gray_Reference_8618","isReference":true,"layerType":"ArcGISTiledMapServiceLayer","maxScale":70.531073500000005,"minScale":591657527.591555,"opacity":1,"title":"World Dark Gray Reference","url":"https://services.arcgisonline.com/arcgis/rest/services/Canvas/World_Dark_Gray_Reference/MapServer","visibility":true}],"title":"Dark Gray Canvas"},"referenceScale":0,"spatialReference":{"wkid":102100,"latestWkid":3857},"version":"2.9","authoringApp":"RuntimeSDK","authoringAppVersion":"100.6.0.2513"}

the JSON returned by referencing the URL via browser: (like https://<server>/rest/content/items/<webmapid>/data

{"operationalLayers":[],"baseMap":{"baseMapLayers":[{"id":"World_Imagery_2017","layerType":"ArcGISTiledMapServiceLayer","url":"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer","visibility":true,"opacity":1,"title":"World Imagery"}],"title":"Imagery"},"spatialReference":{"wkid":102100,"latestWkid":3857},"authoringApp":"WebMapViewer","authoringAppVersion":"10.6.1","version":"2.11","referenceScale":0}

  • They are different. Note how the .NET returned identically to the one above before the change, keeping with the dark grey basemap, which is incorrect. The browser reference updated with the imagery basemap, as it should have.

Again, thank you, just a little more info, sorry for the length.

0 Kudos
AdrianShephard
New Contributor II

I found the issue. Well, my IT guy found the issue after playing around with my app.

IE CACHE. Apparently, when my .NET application was making a request to our GIS server on site, it goes through IE CACHE to load resources. However, it DOES NOT go through IE CACHE when requesting an online resource and retrieves the latest (like ArcOnline); hence the confusion.

To get the latest update from the server, I have to use CCleaner to wipe IE CACHE data. It then loads the most recent web map from our GIS server. This is not required for online resources. I will have to figure out a way to remove or ignore that IE CACHE data in the app. Relying on clients to set cache to off in Internet Options is not a solution.

I figured it was a caching issue, but I was assuming our server deployment was caching for performance; I ruled out the client computer as it 'felt like' more of a server side problem.

This was not due to my own code. I had the same issue from forks off of GitHub of projects directly from Esri. Maybe disabling IE CACHE is a standard and I'm an idiot for not realizing it, but it might be a good thing to have noted somewhere in SDK documentation. It drove me insane.

Client: .NET SDK 100.6.0, Esri.ArcGISRuntime.WPF, Windows 10
Server: ArcEnterprise 10.6.1 Windows

0 Kudos