-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Redirecting problem in Internet Explorer 11 (IE11) #17434
Comments
Quick and dirty solution - extending the Response class and overriding redirect() class CResponse extends \yii\web\Response
{
/**
* @inheritdoc
*/
public function redirect($url, $statusCode = 302, $checkAjax = true)
{
$browser = Yii::$app->browser;
$browserName = $browser->getName();
if (Yii::$app->getRequest()->isAjax
&& ($browserName === $browser::IE)
) {
return parent::redirect($url, 308, $checkAjax);
} else {
return parent::redirect($url, $statusCode, $checkAjax);
}
}
} |
@art40100 what's |
This should work in JS to use the frameworks redirect handling. var ua = window.navigator.userAgent;
if (ua.indexOf('MSIE ') > 0 || ua.indexOf('Trident/') > 0 || ua.indexOf('Edge/') > 0) {
$(document).ajaxSend(function(event, jqXHR, ajaxOptions) {
jqXHR.setRequestHeader('X-Ie-Redirect-Compatibility', 'true');
});
} |
in config/main.php 'components' => [
'browser' => [
'class' => 'Sinergi\BrowserDetector\Browser',
]
]; A library installed in my project via composer (https://packagist.org/packages/sinergi/browser-detector) |
OK. That may work for you but isn't a good solution for the framework. |
…e codes (`XMLHttpRequest: Network Error 0x800c0008`) fix yiisoft#17434
…r Internet Explorer 11 AJAX redirect bug in case of 301 and 302 response codes (`XMLHttpRequest: Network Error 0x800c0008`)
yii2/framework/web/Response.php Line 873 in 561242b
The fix applyed breaks compatibility by removing check for yii2/framework/web/Response.php Line 867 in 2927a7a
There are special windows versions (for tablets or IoT devices) that send custom user agent that does not include standard IE11 signature checked by
It could be usefull to refactor the code to be able to activate this IE11 hack using request headers as before release 2.0.26 and maybe add a \yii\web\Response flag |
This is true. I do not know that I did not notice the other versions of IE checking. if (ua.indexOf('MSIE ') > 0 || ua.indexOf('Trident/') > 0 || ua.indexOf('Edge/') > 0) {
xhr.setRequestHeader('X-Ie-Redirect-Compatibility', 'true')
} |
What steps will reproduce the problem?
Performing an ajax request and doing a redirect from it.
(Issue when using Internet Explorer 11 (IE11))
Related (same issue) #9670
What is the expected result?
A successful redirect to given URL in function Response::redirect()
What do you get instead?
No redirect!
Additional info
Using 308 statusCode (default is 302) solves the problem in general but it is probably not the right way to do this.
return Yii::$app->getResponse()->redirect(['aaa/view', 'id' => $this->lid], 308);
The text was updated successfully, but these errors were encountered: