2016-09-18 16:18:01 4222次浏览 4条回答 2 悬赏 10 金钱

QQ截图20160918161508.jpg
没登录的情况下,在ie8浏览器中无法跳转到登录页面,直接到403页面了,初步判断是ie8的头信息有问题,

  • 回答于 2016-09-18 16:57 举报

    或许跟js脚本有关,可尝试添加兼容ie8的jquery试试

    2 条回复
    回复于 2016-09-18 17:33 回复

    我看他源代码,还没走到js那步,在 yii/web/user.php 文件下的loginRequired 方法就直接抛出异常了

    回复于 2016-09-19 17:07 回复

    你把异常给截图出来啊。

  • 回答于 2016-09-18 18:11 举报

    尝试下 在当前浏览器 访问index,控制器里面直接$this->redirect();跳转成别的.如果不能,那就是你的ie8读取header有问题了。

  • 回答于 2017-02-08 18:29 举报

    yii/web/user.php 文件下的loginRequired 方法:重定向登录去掉$canRedirect判断就好
    public function loginRequired($checkAjax = true, $checkAcceptHeader = true)

    {
        $request = Yii::$app->getRequest();
        $canRedirect = !$checkAcceptHeader || $this->checkRedirectAcceptable();
        if ($this->enableSession
            && $request->getIsGet()
            && (!$checkAjax || !$request->getIsAjax())
            && $canRedirect
        ) {
            $this->setReturnUrl($request->getUrl());
        }
    //  if ($this->loginUrl !== null && $canRedirect) {
        if ($this->loginUrl !== null ) {
            $loginUrl = (array) $this->loginUrl;
            if ($loginUrl[0] !== Yii::$app->requestedRoute) {
                return Yii::$app->getResponse()->redirect($this->loginUrl);
            }
        }
        throw new ForbiddenHttpException(Yii::t('yii', 'Login Required'));
    }
    
  • 回答于 2017-12-05 15:14 举报

    在调用的时候 $this->loginRequired() 改为 $this->loginRequired(true,false),可以解决问题!
    第二个参数为false的时候,不会去验证浏览器的类型。。默认只有 text/html 会允许跳转。。但是ie8传过来的内容有问题!!

    觉得很赞
您需要登录后才可以回答。登录 | 立即注册
windyy
总监

windyy

注册时间:2015-05-28
最后登录:2018-07-31
在线时长:32小时5分
  • 粉丝6
  • 金钱3150
  • 威望0
  • 积分3470

热门问题