We use SiteMinder authentication in our application.
If app user tries to navigate to a particular page https://ourapp.com/myapp/#/pending/requests in our app via direct URL or via bookmarked URL, SiteMinder will redirect to a login page via 302 redirect similar to http://ourapp.com/login?redirect=https%3A%2F%2Fourapp.com%2Fmyapp%2F#/pending/requests asking for user to enter credential in a login form. After successful authentication, user should be redirected to our app and land on the requested page(/pending/requests).
It's working absolutely fine in Chrome and Firefox. When it comes to IE it's landing on https://ourapp.com/myapp/#/home (default landing page) instead of https://ourapp.com/myapp/#/pending/requests.
I have tried various solutions provided in google search results in our app code like,
- Removing
<base>tag inindex.html - Adding below lines of code at top of the page
// setting location back
window.location = window.location;
// setting location hash back
window.location.hash = window.location.hash;
- Few other solutions similar to above
Though this Q & A perfectly makes sense,
I still want to preserve the URL hash fragment in IE even it's 3xx redirect for my requirement...!?
Answering my own Question
I figured out that after successful authentication,
SiteMinderis doing302 redirectionto user requested application page by using login form hidden variablevalue(where it stores user requested URL/myapp/-without hash fragmentsince it won't be sent to the server) with name similar toredirect. Sample form belowSince
redirecthidden variable value contains only/myapp/without hash fragment and it's a 302 redirect, the hash fragment is automatically removed by IE even before coming to our application and whatever the solutions we are trying in our application code are not working out.IE is redirecting to
/myapp/only and it is landing on default home page of our apphttps://ourapp.com/myapp/#/home.Have wasted almost a day to figure out this behavior.
The solution is:
Have changed the login form hidden variable (
redirect) value to hold the hash fragment by appendingwindow.location.hashalong with existing value. Similar to below codeAfter this change, the
redirecthidden variable is storing user requested URL value as/myapp/#/pending/requestsandSiteMinderis redirecting it to/myapp/#/pending/requestsin IE.The above solution is working fine in all the three browsers
Chrome, Firefox and IE.Thanks to @AlexFord for the detailed explanation and providing solution to this issue.