esri.setRequestPreCallback not firing on MapServer export request

2606
2
08-16-2013 10:29 AM
BillDaigle
Occasional Contributor III
I am trying to add a token to my map service requests using esri.setRequestPreCallback.  This seems to work fine for fetching info from the rest services page, but for some reason the function doesn't fire when the image is requested.

Here is a jsFiddle that illustrates the problem:
http://jsfiddle.net/SVZPy/

You will notice that the callback fires when the layer created, but not when the layer is added to the map.  Nor does it fire if f you pan the map.

Any thoughts?
2 Replies
JasonZou
Occasional Contributor III
esri.setRequestPreCallback only fires "just before esri.request calls into dojo IO functions such as dojo.rawXhrPost and dojo.io.script.get." Adding the layer to the map object won't cause any dojo io functions. That's why it won't be triggered. If you want to access the secured map service, you can use proxy server and add the token to the map service url via proxy config file. Here is the link for the details: https://developers.arcgis.com/en/javascript/jshelp/ags_secureservices.html.
0 Kudos
BillDaigle
Occasional Contributor III
I was afraid of that.  I'm already using a proxy to generate the token, but I'm trying to avoid sending every single request through the application server.  In the past, I've appended the token to every secure URL before making the request.  I was hoping  esri.setRequestPreCallback might get around this.  Guess not.  It guess it might be time to wrap my brain around the identityManager.
0 Kudos