I just upgraded to ArcGIS server 10.3, and I still can't print with secure map service.

I embedded username and password in my web Application (visual studio .NET 2013 C#).

I saw this issue in the previous versions in the error list. But I thought they fixed this issue in 10.3 . Does anybody else still have this problem?


(worked with ArcGIS 10.1)

well.. I was struggling with this problem almost for a year now. I just came up with a workaround. The only thing you need to do is to generate a Short-lived Token every time your page loads. I did it in my Login Page and put it in Session. I try to explain it step by step:

1-Generating a short-lived Token

  • As you may know, Printing Tasks wont work with Long-lived tokens and Short-Lived Tokens will expire after a while ( you can set the lifespan in ArcgisManager/Security ) . So you have to Generate Short-lived token server-side and save it in session.DONT DO IT CLIENT-SIDE(because you will expose the credentials and what's the point of securing the map in the first place!?). Here you can find how to generate tokens server-side C# - Access content from ArcGIS Online

    2-Applying the short-lived token

  • To avoid the Arcgis authentication windows dialog you have to setup your proxy.config and apply it to your esriconfig :

       esriConfig.defaults.io.proxyUrl = "proxy/proxy.ashx";
       esriConfig.defaults.io.alwaysUseProxy = true;
  • Then append the token to the end of your ArcGISDynamicMapServiceLayer address:

        var GeneratedToken = document.getElementById("HiddenTokenTB").value;
        var dynamiclayersURLForPrint = AGS_SERVICE_PREFIX + "/" + MAP_SERVICE_NAME + "/MapServer" + "?token=" + GeneratedToken;

    EDIT : I should say that you should make a Map object just for printing( with the token ). Dont add the token to the map you are showing( that will mess up your legend and TOC ). Before you are trying to Print the map , just pass the Map object that you made for printing.

Get the extent of the original map first.

printmap.extent = map.extent;

printer = new Print({
              map: printmap,
              templates: [template],
              url: printUrl
          }, dom.byId("printButton"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.