Proxy page within .Net MVC web app?

1501
3
05-30-2013 09:22 AM
AlexGolebiewski
New Contributor
Can the .net proxy page live within a .cshtml Razor view in a MVC 3 app? If so, are there any examples there showing this? I keep getting a sitemap error when trying to use the asp.net proxy page.
0 Kudos
3 Replies
ShadCampbell
New Contributor III
Perhaps I don't understand your question... but why not just add them to the root of your project?  This works for me??
[ATTACH=CONFIG]24836[/ATTACH]

Then in the JavaScript I just include...
esri.config.defaults.io.proxyUrl = "/proxy.ashx";
0 Kudos
SteveLettau
New Contributor
Does anyone have any more experience with this in MVC4?  I need to implement the proxy to perform buffers and spatial queries using polygon geometry.  I can successfully run my code against a single web map HTML page, but now I need to integrate into my MVC4 project.

I added the proxy.ashx and proxy.config to the root of my project, it dies on the geoServer.buffer.  Below is the code that works in the standalone page but not in my MVC app.  Does anyone have any ideas?

In init function:

esri.config.defaults.io.proxyUrl = "/proxy/proxy.ashx";


In partialview:

            geoService = new esri.tasks.GeometryService("http://<domain:port>/arcgis/rest/services/Utilities/Geometry/GeometryServer");
            bufferParams = new esri.tasks.BufferParameters();
            bufferParams.unit = esri.tasks.GeometryService.UNIT_METER;
            var bsr = new esri.SpatialReference({ wkid: 102100 });
            bufferParams.bufferSpatialReference = bsr;
            bufferParams.outSpatialReference = bsr;
            bufferParams.geodesic = true;
            bufferParams.distances = [-4];

            var geometry = geoPoly.geometry;
            bufferParams.geometries = [geometry];
            geoService.buffer(bufferParams, function (result) {
                var graphic = new esri.Graphic(result[0], selectionSymbol);
                var bufferGeometry = graphic.geometry;
                zoningQuery.geometry = bufferGeometry;
                zoningQueryTask.execute(zoningQuery, showZoningResults);
            }, onError);
0 Kudos
SteveLettau
New Contributor
Turns out it did work fine, I'd forgotten to set:

query.returnGeometry = true;


Proxy page works fine in MVC4.

Steve
0 Kudos