且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

302登录重定向后IE删除的URL片段

更新时间:2023-09-28 23:49:10

回答我自己的问题

我发现,成功认证后,SiteMinder通过使用登录表单隐藏变量value (在其中存储用户请求的URL /myapp/)对用户请求的应用程序页面执行302 redirection. -without hash fragment,因为它不会被发送到服务器),其名称类似于redirect.下面的示例表格

Answering my own Question

I figured out that after successful authentication, SiteMinder is doing 302 redirection to user requested application page by using login form hidden variable value (where it stores user requested URL /myapp/ - without hash fragment since it won't be sent to the server) with name similar to redirect. Sample form below

由于redirect隐藏变量 value 仅包含/myapp/,没有散列片段,并且是302重定向,因此即使在进入我们的应用程序之前,IE也会自动删除该散列片段,无论我们使用什么解决方案尝试我们的应用程序代码无法解决问题.

Since redirect hidden 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仅重定向到/myapp/,并且它已登陆我们应用程序https://ourapp.com/myapp/#/home的默认主页.

IE is redirecting to /myapp/ only and it is landing on default home page of our app https://ourapp.com/myapp/#/home.

浪费了几乎一天的时间来弄清这种行为.

Have wasted almost a day to figure out this behavior.

已更改登录表单隐藏变量(redirect),以保留哈希片段 将window.location.hash与现有值一起附加.类似于下面的代码

Have changed the login form hidden variable (redirect) value to hold the hash fragment by appending window.location.hash along with existing value. Similar to below code

$(function () {
  var $redirect = $('input[name="redirect"]');
  $redirect.val($redirect.val() + window.location.hash);
});

此更改之后,redirect隐藏变量将用户请求的URL值存储为/myapp/#/pending/requests,而SiteMinder会将其重定向到IE中的/myapp/#/pending/requests.

After this change, the redirect hidden variable is storing user requested URL value as /myapp/#/pending/requests and SiteMinder is redirecting it to /myapp/#/pending/requests in IE.

上述解决方案在所有三个浏览器Chrome, Firefox and IE中均能正常工作.

The above solution is working fine in all the three browsers Chrome, Firefox and IE.

感谢@AlexFord提供的详细信息解释并提供解决方案.

Thanks to @AlexFord for the detailed explanation and providing solution to this issue.