Here's what I'm using:
JSAPI v3.20
ArcGIS Server 10.3
ASP.NET Proxy 1.1.0
ASP.NET 4.0
I am having an issue when printing a map using Print (Print | API Reference | ArcGIS API for JavaScript 3.20 ). This occurs only after entering an address into the Search widget, and then plotting the result - the request is blocked during any export attempt after this action.
The issue "Unexpected token <" results from the API expecting a JSON response, but getting an HTML page... the page in question is a custom error page capturing a Microsoft validation issue with "potentially dangerous content". Here's the request going through Fiddler:
{
"mapOptions": {
"showAttribution": false,
"extent": {
"xmin": -9758929.205244847,
"ymin": 5153837.351343746,
"xmax": -9757291.78077969,
"ymax": 5155062.73245334,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
},
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
},
"scale": 4513.98870499674
},
"operationalLayers": [{
"id": "layer0",
"title": "layer0",
"opacity": 1,
"minScale": 591657527.591555,
"maxScale": 70.5310735,
"url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer"
},
{
"id": "map_graphics",
"opacity": 1,
"minScale": 0,
"maxScale": 0,
"featureCollection": {
"layers": [{
"layerDefinition": {
"name": "pointLayer",
"geometryType": "esriGeometryPoint"
},
"featureSet": {
"geometryType": "esriGeometryPoint",
"features": [{
"geometry": {
"x": -9758110.34234326,
"y": 5154449.96419052,
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
}
},
"attributes": {
"Addr_type": "StreetName",
"Match_addr": "Main Ave, Chicago, Illinois, 60613",
"StAddr": "Main Ave",
"City": "Chicago",
"score": 100,
"searchTheme": "arcgisSearch",
"searchResult": "Main Ave, Chicago, Illinois, 60613",
"searchMoreResults": "moreResults",
"searchMoreResultsItem": "moreItem",
"searchMoreResultsId": "search_more_results",
"searchMoreResultsHtml": ""
},
"symbol": {
"angle": 0,
"xoffset": 6.75,
"yoffset": 13.5,
"type": "esriPMS",
"url": "https://js.arcgis.com/3.20/esri/dijit/Search/images/search-pointer.png",
"width": 27,
"height": 27
},
"infoTemplate": {
"title": "Search result",
"content": "<div class=\"${searchTheme}\"><div id=\"${searchMoreResultsId}\" class=\"${searchMoreResults}\"><div class=\"${searchMoreResultsItem}\">${searchResult}</div><div>${searchMoreResultsHtml}</div></div></div>"
}
}]
}
}]
}
},
{
"id": "layer1",
"title": "layer1",
"opacity": 1,
"minScale": 591657527.591555,
"maxScale": 70.5310735,
"url": "https://services.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Reference/MapServer"
}],
"exportOptions": {
"outputSize": [800,
1100],
"dpi": 96
},
"layoutOptions": {
"titleText": "My map title",
"copyrightText": "My map copyright text",
"scaleBarOptions": {
"metricUnit": "esriKilometers",
"metricLabel": "km",
"nonMetricUnit": "esriMiles",
"nonMetricLabel": "mi"
},
"legendOptions": {
"operationalLayers": []
}
}
}
...it appears the info window content HTML is the culprit. In my proxy web.config, if I revert validation to 2.0:
<httpRuntime requestValidationMode="2.0" />
...the request works. This is because .NET 2.0 only validates page requests, whereas 4.0 validates ALL HTTP requests. I'd like to call it a day and just implement the web.config change, but I'm wary about making such a modification due to XSS/security concerns. I thought about maybe encoding/decoding, but there doesn't seem to be a way to do this without modifying the JSAPI directly.
Anyone have any ideas? Geonet is pretty quiet about this issue... Is it a bug? Print works fine otherwise!
Thank you!