Select to view content in your preferred language

problem with setting up proxy

4984
11
Jump to solution
04-22-2016 06:20 AM
Mariagomez1
Occasional Contributor

I just want to load a map service using proxy. I read all of instructions for setting up proxy and proxy set up problems that are asked but I could not solve my problem.

I did following steps:

1- I downloaded the proxy files for .Net. They are proxy.ashx and proxy.config that I put them in a folder named proxy on

my server under inetpub/wwwroot.

2- I edited proxy.config file to contain the paths to my local services.

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

<ProxyConfig allowedReferers="*"

             mustMatch="true">

    <serverUrls>

        <serverUrl url="http://localhost:6080.com"

                   matchAll="true"/>

    </serverUrls>

</ProxyConfig>

First question: I changed url="http://services.arcgisonline.com" to url="http://localhost:6080.com". is it right?

3- I went into IIS Manager and create an application from proxy folder.

My index html code in inetpub/wwwroot:

<!DOCTYPE html>

<html>

  <head>   

    <link rel="stylesheet" href="arcgis_js_api/library/3.14/3.14/esri/css/esri.css">

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

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

    <title>Create Map and add a dynamic layer</title>

    <style>

      html, body, #mapDiv{

        padding: 0;

        margin: 0;

        height: 100%;

      }

    </style>

    <script src="arcgis_js_api/library/3.14/3.14/init.js"></script>

    <script>

      var map;

      require([

        "esri/map",

        "esri/config",

        "esri/layers/ArcGISDynamicMapServiceLayer",

        "esri/geometry/Extent",

        "esri/layers/ImageParameters",

       

      ], function (

        Map,esriConfig, ArcGISDynamicMapServiceLayer,Extent, ImageParameters) {      

    

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

        esriConfig.defaults.io.alwaysUseProxy = true;     

       

        var bounds = new Extent({

        "xmin":817962,

        "ymin":-187036,

        "xmax":1566109,

        "ymax":785554,

        "spatialReference":{"wkid":32640}

          });

         

        map = new Map("mapDiv", {

          extent: bounds

        });        

       

        var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services    /sdeMXD/MapServer", {

          "opacity" : 0.5    

        });

        map.addLayer(dynamicMapServiceLayer);

      });

    </script>

  </head>

<body>   

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

</body>

</html>

This is the error in firebug:

GET http://localhost:6080/arcgis/rest/info?f=json

200 OK

                                                              51ms

init.js (line 152)

SyntaxError: expected expression, got '<'                                                                                         proxy.a...allback (line 1)
<%@ WebHandler Language="C#" class="proxy" %> 

                                                                                                                                                            

dojo.io.script error RequestTimeoutError: Timeout exceeded { message="Timeout exceeded", stack=".cache["dojo/errors/crea...

                                                                                                                                                                       init.js (line 1488)

I spend long time but i could not find out what is wrong with it. I really appreciate it if anybody help me.Thanks in advance

Maria Gomez

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Maria,

  To attach files in GeoNet you need to click the "Use advanced editor" link in the upper right corner of the reply window. This option is not available from inside the inbox so you will have to open the thread and then you will see this option. Once you click the "Use advanced editor" then in the lower right corner of the reply window there will be an attach link.

Nothing jumps out as wrong with your proxy.config. but try replacing with this one anyway.

When you are trying to bring up your page you are using

http://localhost/index.html

Right? Not  http://localhost:6080/index.html?

View solution in original post

11 Replies
RobertScheitlin__GISP
MVP Emeritus

Maria,

  To start, No

<serverUrl url="http://localhost:6080.com"

                   matchAll="true"/>

Is not correct. It needs to be:

<serverUrl url="http://localhost:6080"

                   matchAll="true"/>

In step 3 did you make sure you paid attention to this note

Make sure the "Application pool" is at least 4.0.

Did you test your proxy using http://localhost/proxy/proxy.ashx?ping

This line in your code

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

Would mean that this html doc is in some folder inside of the inetpub/wwwroot folder (because ./ means go up to the parent folder).

Mariagomez1
Occasional Contributor

Thanks Robert for your quick answer.

1- I changed  url="http://localhost:6080.com" to url="http://localhost:6080"

2- I set application pool as ASP.NET V4.0    - is it right?

3- I did not know how to test proxy (http://localhost/proxy/proxy.ashx?ping)

    I just copy the url in browser and it gave me following answer:

{ "Proxy Version": "1.1.0", "Configuration File": "OK", "Log File": "Not Exist/Readable"}

Is proxy working correctly?

4- yes my html file ( index.html) is in inetpub/wwwroot  so its directory is   inetpub/wwwroot /index.html

  and proxy directory is  inetpub/wwwroot /proxy/proxy.ashx

Still I have the mentioned errors.. although I corrected step 1..

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Maria,

  1. Good
  2. Yes that is correct
  3. Yes it is working correct
  4. There is an issue here still. Change you code to esriConfig.defaults.io.proxyUrl = "proxy/proxy.ashx";
Mariagomez1
Occasional Contributor

Dear Robert , I changed esriConfig.defaults.io.proxyUrl = "./proxy/proxy.ashx"; to

esriConfig.defaults.io.proxyUrl = "proxy/proxy.ashx"; but still I have the mentioned errors. What is wrong with it?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Maria,

  When I switch your code to the esri hosted JS API (not your local one) and point to a map service on my machine your code runs fine. So it could be that you are having issue with your Local copy of the API. It is really hard for me to tell.

Mariagomez1
Occasional Contributor

I changed my JS API from local to esri hosted one but still I have the mentioned errors in firefox but

in chrome browser i face with this error:

proxy.ashx?http://localhost:6080/arcgis/rest/services/sdeMXD/MapServer?f=json&dpi=96&transparent=tr…:1

Uncaught SyntaxError: Unexpected token <

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Maria,

  That tells me that you have a syntax error in your proxy.config. Can you attach your proxy.config?

Mariagomez1
Occasional Contributor

I could not find attachment of files so i took a picture from it, and also i pasted its codes here :

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

<ProxyConfig allowedReferers="*"

             mustMatch="true">

    <serverUrls>

        <serverUrl url="http://localhost:6080"

                   matchAll="true"/>

                   

    </serverUrls>

</ProxyConfig>

config.png

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Maria,

  To attach files in GeoNet you need to click the "Use advanced editor" link in the upper right corner of the reply window. This option is not available from inside the inbox so you will have to open the thread and then you will see this option. Once you click the "Use advanced editor" then in the lower right corner of the reply window there will be an attach link.

Nothing jumps out as wrong with your proxy.config. but try replacing with this one anyway.

When you are trying to bring up your page you are using

http://localhost/index.html

Right? Not  http://localhost:6080/index.html?