What is a proxy page?

2895
6
11-08-2011 03:55 AM
GarethMann
New Contributor III
I am new to the Javascript API for ArcGIS. I am trying to get some of the samples working using my own data and ArcGIS Services. I note that many of the samples have this line of code:

//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 buffer operation will not work.  Otherwise it will do a http post to the proxy. 
esriConfig.defaults.io.proxyUrl = "/arcgisserver/apis/javascript/proxy/proxy.ashx"; 
esriConfig.defaults.io.alwaysUseProxy = false; 


I have absoluteluy no clue what any of this means! What is a proxy page? If I am using my own data can I just use the proxyURL provided by ESRI in the sample? If not how do I create my own one?

I tried googling the first comment "identify proxy page to use......." but all that came up in google was the same line from the code samples....
0 Kudos
6 Replies
derekswingley1
Frequent Contributor
Please take a look at the conceptual help topic for using a proxy:  http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp/ags_proxy.htm

Using a proxy is a common technique in web development (not just GIS-based web dev) used to get around limitations imposed by the browser. Specifically, a proxy is used to get around the URL length limit that is present in IE and the same origin policy present in all browsers.

Side note:  please use esri.config as esriConfig was deprecated several releases ago.
0 Kudos
GarethMann
New Contributor III
Thank you.

Wow, using this Javascript API is getting more and more complicated than I had originally imagined. In the instructions you linked to, it says this:

"The proxy page runs on your local web server, not on an ESRI server or on the ArcGIS Server computer (unless your web server also hosts the ArcGIS Server instance). "


So essentially this is saying that the proxy page must reside on the same machine as the one hosting the webpage with the javascript code. Is this correct? For the proxyURL can I not just specify a IP Address to another web server?

The reason I ask this is because the web page I am developing will most likely be hosted on a remote shared web server, I just asked tech support with the hosting company and they informed me that the proxy page would not be allowed in a shared hosting environment for security reasons.

But I do have access to another Web Server that I could put the proxy page on, in fact it is the same machine that has ArcGIS Server and hosts the services that the web page will use. Could I not just specify the URL to that machine as the proxy page location?
0 Kudos
GarethMann
New Contributor III
*Bump Bump*
0 Kudos
derekswingley1
Frequent Contributor
...this is saying that the proxy page must reside on the same machine as the one hosting the webpage with the javascript code. Is this correct?

Yes, your proxy must be on the same machine as your html/css/js files.


For the proxyURL can I not just specify a IP Address to another web server?

You cannot do this. One of the main reasons to use a proxy is so that you can access cross domain resources. If you could use a proxy hosted on another server (AKA a cross domain resource), you wouldn't need a proxy.

Directly asking them if you can set up a proxy page is probably not the best way to phrase the question. Most hosting providers probably don't want to hear that you'd like to use their server as an intermediary to grab content from other sites.

One thing to clarify is that the proxy is server side code to fetch content from a URL. As long as your hosting provider allows you to run server-side code, you can use a proxy page. There are example proxy pages available in PHP, .NET and Java. To use those, you need to specify which domains your proxy can access. This is explained in the comments in each proxy page.
0 Kudos
GarethMann
New Contributor III

As long as your hosting provider allows you to run server-side code, you can use a proxy page.


OK, but the issue is with step 4 in the instructions that you linked to under where it says "ASP.NET", it says to use IIS to create a web application in the "default website" directory of the web server. In our shared hosting account we do not have access to IIS on the web server or the default web site directory.

I do have a control panel which allows me to create 'Virtual Folders", I have used this to create seperate ASP.NET web applications within sub folders of the website. Could I simply put the proxy page in a new "virtual folder" of the website?
0 Kudos
derekswingley1
Frequent Contributor
I do have a control panel which allows me to create 'Virtual Folders", I have used this to create seperate ASP.NET web applications within sub folders of the website. Could I simply put the proxy page in a new "virtual folder" of the website?


I think that should work. I would set it up and give it a shot. Don't be afraid dive in and start trying. Those directions are meant to be as simple as possible to get you up and running when you're working on a local dev machine. When you're in production, it's up to you as to where you put things.
0 Kudos