The return URL for securepage.aspx is usually stored in the context parameter when redirecting to login. Both the ACS login page and the user download version have javascript that requests ACS for the list of identifier providers and then creates login links for each IP address. The version supported by ACS is different in that it will also collect the wctx provided to it and configure each IP login URL to maintain this context. In this way, ACS knows where to redirect the user back after authentication is complete.
The user downloadable login page, however, does not save this context, so you get this behavior, ACS simply redirects you to the return URL that you specified in the ACS configuration, in this case default.aspx.
But you can change your login page to insert this missing parameter. The complication is that this context is conveyed differently depending on the protocol. For LiveID ( WS-Federation ), the incoming wctx can be retransmitted in the outgoing wctx in the liveID login link, but in the "cx" box. Below is some javascript that I added to the CreateIdentityProviderButton () function, which achieves this.
... //Creates a stylized link to an identity provider login page function CreateIdentityProviderButton(identityProvider) { // Some code I stole from fellow stackoverflow member for extracting query parameters =) var urlParams = {}; (function () { var e, a = /\+/g, // Regex for replacing addition symbol with a space r = /([^&=]+)=?([^&]*)/g, d = function (s) { return decodeURIComponent(s.replace(a, " ")); }, q = window.location.search.substring(1); while (e = r.exec(q)) urlParams[d(e[1])] = d(e[2]); })(); var cx = "&cx=" + encodeURIComponent(urlParams.wctx); var idpList = document.getElementById("IdentityProvidersList"); var button = document.createElement("button"); button.setAttribute("name", identityProvider.Name); button.setAttribute("id", identityProvider.LoginUrl + encodeURIComponent(cx)); ...
For Yahoo or Google ( OpenID ), this context is returned to openid.return_to as the context request parameter. Thus, on your login page, you can also edit openid.return_to in your account:
... openid.return_to=https://youracstenant.accesscontrol.windows.net:443/v2/openid?context=<value of the wctx extracted from javascript above> ...
You can write the code for the special case that you are referring to based on the identity provider name you see in the ACS IdentityProvider.js json response.