I'm developing a Web Application that is using the ArcGIS Javascript API. When adding a Feature Layer I'm using the setDefinitionExpression to limit the features that are returned. The expression used can be quite large (greater than 2000 in length). Because the expression can be large, I am attempting to use the Proxy page, however I am seeing unusual results. I am finding that the proxy page is not always used, even though I am using the exact same query expression. I have conformed this by utilizing IE's debugger tool and also using Fiddler.
In my application if I add 2 layers (Tiled and Dynamic) prior to adding the Feature Layer I consistently see that the Proxy page is not being used. I can see via the debugging tools that a POST is being performed directly to my REST service. The content-length is over 6000.
If I add just the Tiled layer prior to adding the Feature Layer, I can see that an attempt is made to use the Proxy page. The proxy page is having issues, therefore my Feature Layer does not get added.
Can someone please explain why the Proxy page is not always used even though it would seem that it should be, given the length of the query string used in the setDefinitionExpession. I am very confused as to why layers added prior to adding a Feature Layer would affect the use of the proxy and why adding the Feature Layer doesn't fail when the proxy is not used.
The first function below shows where I am setting the esriConfig.defaults. The second section of code is from my class (tpsMap) where I am adding a Feature layer.
require(["tps/map",
"esri/config",
"dojo/domReady!"],
function (tpsMap, esriConfig) {
// Setup Esri Config
esriConfig.defaults.io.proxyUrl = "http://phunt-pc/EsriProxy/proxy.ashx"
esriConfig.defaults.io.alwaysUseProxy = false;
// Create and display Map
tpsMap = new tpsMap(oMapConfiguration);
tpsMap.mapQuery = oMapQuery;
tpsMap.createMap("divMap");
});
this._featureLayer = new FeatureLayer(this.mapQuery.FeatureLayer.url,
{
mode: FeatureLayer.MODE_SNAPSHOT,
opacity: 0.50,
infoTemplate: this._getInfoTemplate(this.mapQuery.FeatureLayer.InfoTemplate),
outFields: this.mapQuery.FeatureLayer.OutputFields,
className: "feature"
});
// Limit the features based on the expession
this._featureLayer.setDefinitionExpression(this._getQueryExpression());
this.map.addLayer(this._featureLayer);