AnsweredAssumed Answered

Problems with defined proxy page. What am I doing wrong?

Question asked by csergent08 Champion on Nov 21, 2014
Latest reply on Nov 24, 2014 by csergent08

I am trying to add proxy information to my site and my JavaScript, but it's returning errors. I don't need these urls to be secure. The following is my code for my application and my proxy.config file for the application published at: maps.decaturil.gov/decaturPrint

 

App Code:

 

<!DOCTYPE html>

<html>

    <head>

        <title>Create a Map</title>

        <meta http-equiv="content-type" content="text/html; charset=utf-8">

        <meta name="viewport" content="initial-scale=1,maximum-scale=1, user-scalable=no">

        <link rel="stylesheet" href="http://js.arcgis.com/3.11/dijit/themes/soria/soria.css">

        <link rel="stylesheet" href="http://js.arcgis.com/3.11/esri/css/esri.css">

        <style>

            html, body, #mapDiv

            {

                padding:0;

                margin:0;

                height:100%;

                width:100%;

            }

          

            #feedback

            {

                background: #fff;

                border: 2px solid #666;

                border-radius: 5px;

                bottom: 20px;

                color: #666;

                font-family: arial;

                height: auto;

                left: 20px;

                margin: 5px;

                padding: 10px;

                position: absolute;

                width: 300px;

                z-index: 40;

            }

    

            #feedback a

            {

                border-bottom: 1px solid #888;

                color: #666;

                text-decoration: none;

            }

            #feedback a:hover, #feedback a:active, #feedback a:visited {

                border: none;

                color: #666;

                text-decoration: none;

            }

          

            #note

            {

                padding: 0 0 10px 0;

            }

          

            #info

            {

                padding: 10px 0 0 0;

            }

        </style>

        <script src="http://js.arcgis.com/3.11/"></script>

        <script>

            var map;

            require(["esri/map", "esri/config",

                     "esri/arcgis/utils",

                     "esri/dijit/Print",

                     "esri/geometry/Extent",

                     "esri/layers/ArcGISDynamicMapServiceLayer",

                     "esri/layers/ArcGISTiledMapServiceLayer",

                     "esri/layers/FeatureLayer",

                     "esri/tasks/GeometryService",

                     "esri/tasks/PrintTemplate",

                     "dojo/_base/array",

                     "dojo/dom",

                     "dojo/on",

                     "dojo/parser",

                     "dijit/layout/BorderContainer",

                     "dijit/layout/ContentPane",

                     "dojo/domReady!"], function (Map, esriConfig, arcgisutils, Print, Extent,

                                                  ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer,

                                                  FeatureLayer, GeometryService, PrintTemplate, arrayUtils, dom, on, parser

                                                

            ) {

 

 

                         /* The proxy comes before all references to web services */

                         /* Files required for security are proxy.config, web.config and proxy.ashx

                         - set security in Manager to Private, available to selected users and select Allow access to all users who are logged in

                         (Roles are not required)

                         /*

                         The proxy section is defined on the ESRI sample. I have included it as

                         part of the documentation reads that the measuring will not work.

                         I thought that might be important.

                         */

 

 

                         // Proxy Definition Begin

                         //identify proxy page to use if the toJson payload to the geometry service is greater than 2000 characters.

                         //If this null or not available the project and lengths operation will not work.

                         // Otherwise it will do a http post to the proxy.

                         esriConfig.defaults.io.proxyUrl = "proxy.ashx";

                         esriConfig.defaults.io.alwaysUseProxy = true;

 

 

                         // Proxy Definition End

 

 

 

 

                         // set custom extent

                         var initialExtent = new Extent({

                             "xmin": 777229.03,

                             "ymin": 1133467.92,

                             "xmax": 848340.14,

                             "ymax": 1185634.58,

                             "spatialReference": {

                                 "wkid": 3435

                             }

                         });

 

 

                         // create map and set slider style to small

                         var map = new arcgisutils.createMap("mapDiv", {

                             showAttribution: false,

                             sliderStyle: "small",

                             extent: initialExtent

                         });

 

 

                         // add imagery

                         var tiled = new ArcGISTiledMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Aerial_2014_Tiled/MapServer");

                         map.addLayer(tiled);

                         // set operational layers

                         var operationalLayer = new ArcGISDynamicMapServiceLayer("http://maps.decaturil.gov/arcgis/rest/services/Public/InternetVector/MapServer", { "opacity": 0.5 });

                         // add operational layers

                         map.addLayer(operationalLayer);

 

 

                         // declare geometry service

                         esriConfig.defaults.geometryService = new GeometryService("http://maps.decaturil.gov/arcgis/rest/services/Utilities/Geometry/GeometryServer");

 

 

                     }

            );

        </script>

    </head>

    <body class="soria">

        <div id="mapDiv"></div>

    </body>

</html>

 

 

proxy.config file

 

<?xml version="1.0" encoding="utf-8" ?>

<ProxyConfig allowedReferers="*"

             mustMatch="false">

    <serverUrls>

       

        <!-- serverUrl options:

            url = location of the ArcGIS Server, either specific URL or stem

            matchAll = true to forward any request beginning with the url

            token = (optional) token to include for secured service

            dynamicToken = if true, gets token dynamically with username and

              password stored in web.config file's appSettings section.

    -->

        <serverUrl url="http://maps.decaturil.gov/arcgis/rest/services"

                   matchAll="true">

        </serverUrl>

 

 

    </serverUrls>

</ProxyConfig>

 

 

<!-- See https://github.com/Esri/resource-proxy for more information -->

Outcomes