DotNet Proxy - Random login prompts

6806
23
06-24-2016 12:03 PM
ChrisSmith7
Frequent Contributor


Hey guys, I am having a situation where the login prompt randomly shows when using v1.1.0 of the DotNet proxy against secured services (using login-based authentication).

I am unable to reproduce consistently - there's no rhyme or reason - and logging hasn't helped to tamp-down the culprit. I see others have encountered this as well:

Login prompt appearing randomly · Issue #300 · Esri/resource-proxy · GitHub

I had to many problems with login based authentication I just gave up. It seems to be extremely buggy and inconsistent.

Has anyone had any luck in resolving the issue? Bjorn Svensson​, do you have any recommendations for me to try, or maybe some caveats/known issues not indicated on GitHub? If I reload the page, the prompt will disappear and authenticate without having to manually enter credentials. Additionally, manually entering creds allows the app to continue functioning when the prompt displays. Really, it works the majority of the time, but... we need it to work 100% of the time!

A little bit about my set-up, if helpful:

* ArcGIS 10.3 on a Win 2k12 VM

* Web adaptor sourced on another Win 2k12 VM

* v1.1.0 of the DotNet API

* v3.16 of the JSAPI

* secured map service using login auth; xy event layer view from an MS SQL Server slice

* multiple maps embedded within iFrames on the host page; iFrames are hosted from the same server/project

* map service used as a FeatureLayer in the mapping app

Thanks!

0 Kudos
23 Replies
JohnFell
Occasional Contributor III

mikewynne and csgeosol1,

We are experiencing a similar behavior with the DotNet proxy. We have tried many of the solutions already recommended with no real improvement. The random appearance of the login prompt means that after each fix we cross our fingers to hope it does not reappear!

If you are willing, would you please share your code with those of us who also want the prompt to just go away? It would be most appreciated!

0 Kudos
JohnFell
Occasional Contributor III

All,

I decided to investigate the best way to do this for our application. This js is loaded after the map is loaded initially. The id of the widget is consistent so I look for the widget id for the cancel button and just apply the onClick event for the button widget object.

I hope this helps others.

// Handles login error prompt display problem
// by executing a click event for the cancel
// button


// This function specifies the onClick event
// for any login prompt created by the 
// secured service missing the proxy
function HandleLoginError() {
    if (dijit.byId("dijit_form_Button_1")) {
        var cancelButton = dijit.byId("dijit_form_Button_1");
        cancelButton.onClick();
        //alert("Login prompt handled!");
    }
}

// This loop is defined to handle the error
// while the login error prompt is visible
// for multiple secured services.
// The page is reloaded for each failed
// secured service.
while (dijit.byId("dijit_form_Button_1")) {
    HandleLoginError();
    location.reload(true);
}
0 Kudos
ChelseaRozek
MVP Regular Contributor

This looks like it will be very helpful! I'm a novice at js, do you know where I'd stick this in a self-hosted WAB app?

0 Kudos
JohnFell
Occasional Contributor III

Chelsea,

This javascript (e.g., postLoadErrors.js) will need to execute after the main page loads. I am not familiar with web app builder but I imagine that it allows you to customize code in your various website files. You can include a script tag section that loads this page at the end of your main.html or index.html whatever the name of your default page. See example below.

<html>
<body>

<!-- main content -->
<!-- load map -->
<!-- bottom of default.html -->
    script type="text/javascript">
        function downloadJSAtOnloadPostLoadErrors() {
            var element = document.createElement("script");
            element.src = "js/postLoadErrors.js";
            document.body.appendChild(element);
        }
        if (window.addEventListener)
            window.addEventListener("load", downloadJSAtOnloadPostLoadErrors, false);
        else if (window.attachEvent)
            window.attachEvent("onload", downloadJSAtOnloadPostLoadErrors);
        else window.onload = downloadJSAtOnloadPostLoadErrors;
    </script>

</body>
</html>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos