Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect problems in Internet Explorer 11 (IE11) #9670

Closed
Q1WP opened this issue Sep 11, 2015 · 22 comments
Closed

Redirect problems in Internet Explorer 11 (IE11) #9670

Q1WP opened this issue Sep 11, 2015 · 22 comments
Assignees
Labels
Milestone

Comments

@Q1WP
Copy link

Q1WP commented Sep 11, 2015

When I use the included IE debugger and view the response headers, the header is there and the url is correct, but IE11 isn't reading it.

The response error:
pjax-response-error

The response headers:
pjax-response-headers

One comment on StackOverflow suggested using the status code 200, and after testing, this does appear to work. I know the default redirect status code is 302, but this just doesn't work.

Update

I just respond with redirect to ajax request. Page redirects in all browsers except IE. I'm testting in IE11. I'm getting the following error in console: XMLHttpRequest: Network Error 0x2f76, Could not complete the operation due to error 00002f76..

URL for redirect sent in X-Redirect header. yii.js script handles this header, see line 265. var url = xhr.getResponseHeader('X-Redirect');. In case of IE11 getResponseHeader() returns null instead of URL. As I mentioned before I just respond with 200 status at the moment instead of 302.

@SilverFire
Copy link
Member

Duplicates yiisoft/jquery-pjax#26

@SilverFire SilverFire reopened this Nov 24, 2015
@SilverFire SilverFire changed the title Pjax redirect not working in Internet Explorer (IE11) Redirect problems in Internet Explorer 11 (IE11) Nov 24, 2015
@SilverFire
Copy link
Member

Added Update section to the topic. The problem does not really relates Pjax, it's about yii.js and IE

@SilverFire SilverFire added type:bug Bug status:to be verified Needs to be reproduced and validated. and removed feature:pjax labels Nov 24, 2015
@DMGPage
Copy link
Contributor

DMGPage commented Nov 27, 2015

When this bug will be corrected? I have same problem with IE 10 till edge. If I make ajax request and page redirects to login with status code 302, IE throw "SCRIPT7002: XMLHttpRequest: Network Error 0x2f76, Could not complete the operation due to error 00002f76.".

For now I will rewrite loginRequired function to redirect ajax requests with status code 308, but I hope this bug will be corrected soon.

@SilverFire SilverFire removed the status:to be verified Needs to be reproduced and validated. label Nov 27, 2015
@SilverFire SilverFire self-assigned this Nov 27, 2015
@SilverFire
Copy link
Member

Also I don't like 308 code for redirect, because according to the RFC it's a permanent redirect.

The 308 (Permanent Redirect) status code indicates that the target
resource has been assigned a new permanent URI and any future
references to this resource ought to use one of the enclosed URIs.

@SilverFire
Copy link
Member

There is a good article on HabraHabr in Russian, where the author suggests to use 303 code. In the end of the post, there is a tip, that 303 doesn't work in old browsers, but the post was written almost 6 years ago.

So I've tested IE11 with both 303 and 308 redirects:
303: The same error as with 303, no redirect.
308: No error, no redirect. Nothing happens. Absolutely nothing.

@DMGPage
Copy link
Contributor

DMGPage commented Dec 20, 2015

All SO posts are about Yii and you say it's not Yii problem? Sounds like a joke. Especially when yii.js handles redirects. And yes 303 code is not a solution.

@SilverFire
Copy link
Member

I said that it's not a Yii problem since you can easily reproduce it with plain PHP and AJAX.

The root of the problem is X-Pjax-Url header, which is generated instead of Location to redirect client's PJAX request. I guess IE has a pre-filter that marks responses with status-code 302 and without Location header as invalid. X-Redirect is ignored by IE as well.

Since the problem affects all the IE versions (including modern) I think that we should try fix it somehow.
The easiest way is changing Response.php:763 and setting Location header instead if anything else, but it will bring backward incompatibility.

@yiisoft/core-developers do you have any ideas?

@samdark
Copy link
Member

samdark commented Dec 20, 2015

We could probably detect IE and send another header for it.

@SilverFire
Copy link
Member

I'm not happy with the idea of detecting browser versions in the core code =/

@samdark
Copy link
Member

samdark commented Dec 23, 2015

Well, yes but I see no other choice right now.

@SilverFire
Copy link
Member

@yiisoft/core-developers nobody else have a better idea? Or nobody complains about adding such check to the response->redirect() method?

@AnatolyRugalev
Copy link
Contributor

May be pjax can add custom header for problem browsers and yii will detect it? X-Redirect-Compability: 1 for example

@AnatolyRugalev
Copy link
Contributor

And we should have an option in it to disable this new behavior

@SilverFire
Copy link
Member

@AnatolyRugalev that's a better idea!

@SilverFire
Copy link
Member

Please, check out #10483 and yiisoft/jquery-pjax#38

@degibons
Copy link

degibons commented Aug 9, 2017

So, it's only corrected for PJAX. What about regular ajax redirect (handled in other browsers with yii.js RedirectHandler)? In IE it's still not working.

@Fr1ar
Copy link

Fr1ar commented Oct 30, 2017

The problem is still persists for regular ajax redirects in IE & Edge, because HTTP request does not contain header "X-Ie-Redirect-Compatibility" so redirect does not work properly.

@njasm
Copy link
Contributor

njasm commented Nov 23, 2017

I agree with @Fr1ar .
yii should handle this, issue in yii.js RedirectHandler. we're having this problem still.

@vkmel
Copy link

vkmel commented Feb 22, 2018

How to fix this issue? I am getting the same error trying to post json data to controller/action from Javascript using $.ajax. Works well in other browsers.. having issue in IE11.

$.ajax({
type: 'POST',
url: '/site/register-payment',
data: {paymentdata:res},
dataType: 'json'
});

@art40100
Copy link
Contributor

Issue is still ongoing, tested with IE11 and Yii 2.0.12, even latest (to this date) Yii 2.0.22 - has the same issue.

@samdark
Copy link
Member

samdark commented Jul 15, 2019

Please report issue separately. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants