Select to view content in your preferred language

Print dijit, CORS error

4037
13
08-20-2015 08:59 AM
AshleyPeters
Frequent Contributor

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

0 Kudos
13 Replies
MichaelVolz
Esteemed Contributor

Are you using https for your print service?  If so, do you have it set to run synchronous or asynchronous?  There is a bug with https print services running asynchronous.  Not sure if this applies, but you might just want to check out your settings.

0 Kudos
AshleyPeters
Frequent Contributor

David, yes the proxy.config includes a serverUrl for the print server.

Michael, I am using https for the print service. It is set to run synchronous.

After talking with tech support last week and IT staff this morning, it looks like the issue might be caused by the server not recognizing it's public IP address. The IT folks are working on that now, so hopefully once they have that resolved it will resolve my print issue.

Ashley

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Ashley, see if this answer  ​Re: Print Widget Error Out   helps out any. 

I' m still out today, but wanted to make sure your tracking that discussion too.

0 Kudos
YousefQuran
Frequent Contributor

Hi,

This may help you. Replace your URL here ..

require(["esri/config"], function(esriConfig) {
  esriConfig.defaults.io.corsEnabledServers.push("servicesbeta.esri.com");
  esriConfig.defaults.io.corsEnabledServers.push("server.organization.com");
});


more info ..

Regards,
Yusuf

0 Kudos