1

I have a .Net application using the JavaScript API to draw a map. I use the proxy.ashx file to proxy requests to secure map services (dynamic tokens), configured in proxy.config. I added an entry into proxy.config for ArcGIS Online:-

<serverUrl url="http://services.arcgisonline.com/" matchAll="true" />

My JavaScript is as follows:-

    esri.config.defaults.io.alwaysUseProxy = true;
    esri.config.defaults.io.proxyUrl = "/proxy.ashx";

    map = new esri.Map("map", {
        extent: new Extent({
            xmin:174.5, ymin:-39, xmax:174.7, ymax:-38.8,
            spatialReference:{wkid:4326}
        }),
        basemap: "topo"
    });

If I exclude the basemap, my map draws as expected but if I include the basemap (as above), the basemap is drawn partially and I get an infinite loop of null requests occurring:

    GET /proxy.ashx?undefined/tile/NaN/NaN/NaN?blankTile=false HTTP/1.1

I have stripped out all other code to eliminate that as a cause. If I comment out the two lines of JavaScript to use the proxy the basemap works perfectly so the problem has something to do with my proxy.config and/or the proxy.ashx file. Possibly I have an older version old proxy.ashx.

Has anyone seen this error before, or point me in the right direction to get a basemap working with the proxy configuration? I am using JavaScript API 3.8

3

not a direct answer to your question, but since you're using version 3.8 of the API, you can selectively route traffic to secure services through your proxy rather than relying on setting alwaysUseProxy to 'true'.

instead of

esri.config.defaults.io.alwaysUseProxy = true;

you could use

urlUtils.addProxyRule({
    urlPrefix: "traffic.arcgis.com",  
    proxyUrl: "/sproxy"
});

https://developers.arcgis.com/javascript/jsapi/esri.urlutils-amd.html#addproxyrule

see this sample for an example in action: https://developers.arcgis.com/javascript/jssamples/widget_directions_basic.html

| improve this answer | |
  • This works for me so I am no longer worried about fixing the original issue. I tried to upvote your reply but don't have enough points so accepted it as the answer instead. – tr3v Mar 16 '14 at 19:02
  • glad to hear it. i think this is a better approach anyway. :) – John Gravois Mar 17 '14 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.