AnsweredAssumed Answered

Print dijit, CORS error

Question asked by xylochic627 on Aug 20, 2015
Latest reply on Aug 28, 2015 by Yusufamro

I am having a very similar issue as is mentioned here: https://community.esri.com/message/399585. I've added in Print dijit and PrintTemplate task and get a print button. However, when I click it, it changes from Print to Printing, runs for a bit, then changes back to Print. When I check the Firefox developer tools, I get this error:

 

I've added in a proxy on my server and gone through the steps to enable CORS mentioned at enable cross-origin resource sharing. I'm still getting the error.

 

At this point, I'm not sure if it is an issue in my code, or that I need to place the proxy on my local machine, where I'm building. I can't turn on IIS on my local machine, as our IT folks don't allow it.

 

Here's the code I added in for printing and the proxy:

 

esriConfig.defaults.io.proxyUrl = "http://myURL/DotNet/proxy.ashx",
esriConfig.defaults.io.alwaysUseProxy = false;

//Create Printer Layouts Array
var myLayouts = [{
"name": "Print_Landscape",
"label": "Letter (Landscape Orientation)",
"format": "pdf"
}, {
"name": "Print_Portrait",
"label": "Letter (Portrait Orientation)",
"format": "pdf"
}];

//Create Print Templates
var myTemplates = [];
dojo.forEach(myLayouts, function (lo) {
var printTemp = new PrintTemplate();
  printTemp.layout = lo.name;
  printTemp.label = lo.label;
  printTemp.format = lo.format
  myTemplates.push(printTemp);
});

 

And this portion after creation of my map:

 

//Add Print Widget

var PrintWidget = new Print({

map: mapMain,

url: "https://myURL/rest/services/CustomPrint/GPServer/Export%20Web%20Map",

templates: myTemplates

}, "PrintWidg");

PrintWidget.startup();

 

Any help/guidance would be much appreciated! Thank you in advance!

 

Ashley

Outcomes